tgetent() in termlib has a bug

utzoo!decvax!pur-ee!purdue!rlb utzoo!decvax!pur-ee!purdue!rlb
Wed Aug 4 00:42:59 AEST 1982


tgetent() uses a global variable named "hopcount" to detect and reject
long tc= chains in the termcap file.  "hopcount" is assumed to be initially
zero, which it is, and then is incremented and compared to 32 each time
a tc= statement is encountered in termcap.

This causes a problem in programs that call tgetent several times
(notably Gosling's emacs on restarting from a pause) "hopcount"
is never reset to zero, ever.  Thus, if you have one tc= statement
in the capability for your terminal, on your 32nd restart into emacs,
the editor crashes with an "infinite tc= loop" error.  It's even worse
on our ADDS regent 40 terminals which have a tc= chain of about five.

The solution is to place the statement

	hopcount = 0;

near the beginning of tgetent() in termcap.c.

Note that if you use tset to define the TERMCAP environment variable,
this problem doesn't arise since the tc= chains are resolved by tset.

Bob Brown (rlb)
Purdue-CS (317)494-6530



More information about the Comp.bugs.4bsd.ucb-fixes mailing list