Subject: Re: tgetnum - bug or feature?
To: None <current-users@NetBSD.ORG>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: current-users
Date: 04/22/1997 06:54:39

> I've got a piece of code, many moons old, which does something like
> 	width = tgetnum("co");
> This has worked forever.

> Suddenly, it is dumping core.

> Study reveals that running tgetent() before doing this fixes the core
> dump.  No other system I currently have access to requires me to run
> tgetent first.

I am totally astonished that you would even _consider_ calling tgetnum
without having first called tgetent; I am also astonished that it works

> The documentation (which looks fairly pre-ANSI) does not seem to hint
> at a definitive answer.

Nothing _definitive_, perhaps, but the phrasing certainly says to me
that you have to call tgetent first:

	The tgetent function extracts the entry for terminal name into
	the buffer at bp.  The bp argument should be a character buffer
	of size 1024 and must be retained through all subsequent calls
	to tgetnum, tgetflag, and tgetstr.

No hint is given of what happens if you call one of the last three
without having given libtermcap a buffer to use via tgetent.  I'm not a
bit surprised it cores.

> Bug?  Feature?  I could go either way on this, although I slightly
> prefer the behavior I get elsewhere, where tget* all work on the
> current terminal type unless I run tgetent to look at a different
> one.

IMO "elsewhere" is being surprisingly tolerant, letting you get away
without tgetent.

					der Mouse

		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

Version: 2.6.3ia
Charset: latin1