Terminfo()--Ideas needed. System V

Mark Horton mark at cbosgd.UUCP
Tue May 27 15:08:33 AEST 1986


In article <1596 at ecsvax.UUCP> bet at ecsvax.UUCP (Bennett E. Todd III) writes:
>The case of terminal descriptions seems like a middle ground -- people
>have different views. Termcap has the benefits of a readble database
>format. Terminfo is faster in the worst case. How often do you access
>every term[(cap)|info)] description? Not in the lifetime of most UNIX
>systems, I'd imagine.

It's quite true that the analogy isn't exact.  In particular, there are
gobs of applications where shell is more appropriate than C.  From my
experience, I have run across only a single application where termcap
is more appropriate than terminfo.

By the way, I stated earlier that termcap was more convenient for a
development environment.  What I meant was an environment where termcap
or terminfo descriptions are being developed.  If you're developing
something else, then you have a production environment as far as
termcap/terminfo is concerned.

>A termcap database sorted approximately in
>decreasing order of frequency of use should be at least as fast as the
>repeated directory lookups required to descend the terminfo tree -- and
>termcap format is *trivial* to parse.
>
>If speed is what you want, sort /etc/termcap in decreasing order of
>frequency of use. If that's not good enough for you, cram your termcap
>definition in the environment variable TERMCAP and leave terminfo behind
>entirely, when it comes to speed.

I used to think this too.  I was at Berkeley when we decided how to sort
termcap files and put them into the environment.  It helped a lot.

But it turns out that even if you put a termcap in your environment,
it's still too slow.  The termcap algorithm for reading the entry
into a set of capabilities is QUADRATIC on the size of the entry.
This is the nature of the beast - because of tc=, you have to start
from the left for each capability search.  As termcap descriptions got
longer, starting up vi grew slower and slower.  It was taking 1/4 second
of CPU time on a VAX 750 to parse the termcap entry, even when it came
out of the environment.

This was when I decided to move to a compiled format.  Things get much
simpler for the typical user - no need for the whole entry in the
environment anymore, or the hair of tset -s in the .profile/.login.
The ps command was breaking from the huge environment entries that
took the arguments off the top page of memory.  Forks were expensive.
And it took too long to start up vi.  All these problems went away
when terminfo was compiled.

Termcap format is trivial to parse, IF you are willing to put up with
some of the disadvantages of interpreters, such as no error messages,
slow speed, and the size of the parser.  If you wanted to get good
error messages, termcap would be as hard to parse as terminfo.  (For
those who are not impressed with tic's error messages, the SVr2 tic,
which was frozen for SVr2 in April 1983 along with the rest of curses,
is essentially the termcap parser.  The SVr3 tic is completely redone,
by Pavel Curtis, and it's as fussy as pcc.)

And I'm sorry you can't get SVr3 yet, and that in the meantime you're
all using 3 year old code.  We don't control the release dates, and
curses hasn't been what's holding up SVr3.  You might look to see if
you got the "ti4" program with SVr2, which dumps out a terminfo binary,
although not in tic-readable form.  I think it was in the source dir
but not normally installed.  It's the only tool we had for printing
out the binaries back in 1983.

	Mark



More information about the Comp.unix.wizards mailing list