[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why are tty-char.tmac and tty.tmac separate files?

From: Dave Kemper
Subject: Why are tty-char.tmac and tty.tmac separate files?
Date: Sun, 10 Jul 2022 16:55:41 -0500

Why are tmac/tty-char.tmac and tmac/tty.tmac separate files?  They
both seem to serve essentially the same purpose: providing fallback
character sequences for characters that may not exist in the terminal
environment's encoding (especially the limited sets available to ASCII
and Latin-1).

But they are called from different places: grotty's man page specifies
that troffrc loads tty.tmac automatically for any terminal device;
thus, these two commands, using a character defined in tty.tmac, both
produce the same output:

$ echo '\[lh]' | nroff | cat -s
$ echo '\[lh]' | groff -Tascii | cat -s

But, as its man page says, the nroff script specifies tty-char.tmac,
which means that whether this file is loaded depends on which command
is used.  This example uses a character defined in tty-char.tmac:

$ echo '\[dg]' | nroff | cat -s

$ echo '\[dg]' | groff -Tascii | cat -s
troff: <standard input>:1: warning: can't find special character 'dg'


There may be a valid reason for this separation, but I'm not sure what
it is.  What are the use cases where a user wants one set of
definitions but not the other?

A comment in tty-char.tmac (reiterated on the nroff man page) gives
some small hint: "the optical appearance of the definitions contained
in this file is inferior... to those of the replacement characters
defined in the file tty.tmac."  But this must be a statement in
general terms, as only one character is defined in both files:

$ egrep -h '^\.(f|tty-)char ' tmac/tty*.tmac | cut -f2 -d\ > /tmp/sym
$ diff <(sort /tmp/sym) <(sort -u /tmp/sym)
< \[sd]
$ rm /tmp/sym
$ fgrep '\[sd]' tmac/tty*
tmac/tty-char.tmac:.tty-char \[sd] ''
tmac/tty.tmac:.fchar \[sd] \[dq]

(And in this case, which fallback definition of the arc-second sign is
"superior" is a judgment call, but whichever one it is ought to be
used across the board.  Both are pure ASCII; \[dq] is ASCII 34, the
straight double-quote character.)

So the upshot isn't that using only tty.tmac gives "better" results;
the upshot is that using only tty.tmac leaves some character escapes
undefined for terminals, provoking warnings and omitting information
from the output.

And in a couple of cases, tty.tmac (the file that's always loaded)
seems to presume the loading of tty-char.tmac (the file that's NOT
always loaded): tty.tmac defines two glyphs in terms of \[rn], but
\[rn] is defined for terminal devices in tty-char.tmac.

Does these files being separate serve some purpose, or is it an
evolutionary accident?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]