[net.bugs.4bsd] bug in tgetent

rtm (08/05/82)

----- News saved at Thu Aug  5 07:38:06 1982

tgetent() is a recursive function. Every time it sees
tc= it calls itself to find the description of the
specified terminal. If you set hopcount to zero each
time tgetent() is called, you defeat it's purpose,
which is to count the recursive calls to tgetent().
What you really want is to rename tgetent() _tgetent(),
and make a routine called tgetent() with the same arguments
as the old tgetent() (now _tgetent()) that sets hopcount = 0
and calls _tgetent() with its arguments.

thomas (08/08/82)

If you're going to make a separate routine for recursing, then you
can just add the depth as an argument:

tgetent(bp, name)
char *bp, *name;
{
	_tgetent(bp, name, 0);
}

_tgetent(bp, name, depth)
char *bp, *name;
{
	if (depth > 32) 
		/* Do Error Stuff */
	else
	{
		....
		/* tc= processing */
		_tgetent(bp, newname, depth+1);
		....
	}
}

=Spencer