[net.news.b] Fix to vnews

john@genrad.UUCP (John Nelson) (10/13/83)

Vnews  2.10.1 is  supposed  to  display  an article  posted to  multiple
newsgroups  only ONCE  (even if those  newsgroups  are read in  multiple
sessions.)  Our  copy of  vnews  was not  only not  doing  that,  it was
displaying  articles  posted  to  multiple  newsgroups  in  ALL  of  the
newsgroups  unconditionally.  I tracked the problem  down to the call to
"ngmatch" in the function  rightgroup() in the file visual.c Our version
of ngmatch  is  clearly  commented  as  needing an NGDELIM at the end of
each   argument   string   (NGDELIM  is  a  comma)  which  the  function
rightgroup()  in vnews was not providing (it set up a null terminator at
the end of the news group  name).  Therefore  I put in a little  hack to
fix the  problem. I do not claim this is the most  efficient  way to fix
the problem, but I am not the normal news  maintainer  at this site, and
I didn't  want to spend a lot of time on the  problem.  I  included  the
fixed subroutine rightgroup() with my hack clearly commented as "JPN". 

By the way, it's possible that I missed a posted fix for either vnews or
ngmatch(), if so I'm sorry.

/*
 * Code to avoid showing multiple articles for vnews.
 * Works even if you exit vnews.
 * Returns nonzero if we should show this article.
 */
rightgroup(hp)
	struct hbuf *hp;
	{
	char ng[BUFLEN];
	char temp[BUFLEN];				/* JPN */
	register char *p, *g;
	int i, flag;

	strcpy(ng, hp->nbuf);
	ngcat(ng);
	g = ng;
	flag = 1;
	while ((p = index(g, ',')) != NULL) {
		*p++ = '\0';
		while (*p == ' ')
			p++;
		if (strcmp(g, groupdir) == 0) {
			return flag;
		}
		/* this hack required because ngmatch expects trailing ',' */
		strcpy(temp, g);			/* JPN */
		strcat(temp, ",");			/* JPN */
		/* if (ngmatch(g, header.nbuf) */	/* JPN */
		if (ngmatch(temp, header.nbuf)		/* JPN */
		 && ((i = findrcline(g)) < 0 || index(rcline[i], '!') == NULL)) {
			flag = 0;
		}
		g = p;
	}
	/* we must be in "junk" or "control" */
	return 1;
}