Previous: , Up: gtroff Reference   [Contents][Index]


5.34 Implementation Differences

GNU troff has a number of features that cause incompatibilities with documents written with old versions of troff.

Long names cause some incompatibilities. UNIX troff interprets

.dsabcd

as defining a string ‘ab’ with contents ‘cd’. Normally, GNU troff interprets this as a call of a macro named dsabcd. Also UNIX troff interprets \*[ or \n[ as references to a string or number register called ‘[’. In GNU troff, however, this is normally interpreted as the start of a long name. In compatibility mode GNU troff interprets long names in the traditional way (which means that they are not recognized as names).

Request: .cp [n]
Request: .do cmd
Register: \n[.C]

If n is missing or non-zero, turn on compatibility mode; otherwise, turn it off.

The read-only number register .C is 1 if compatibility mode is on, 0 otherwise.

Compatibility mode can be also turned on with the -C command line option.

The do request turns off compatibility mode while executing its arguments as a gtroff command. However, it does not turn off compatibility mode while processing the macro itself. To do that, use the de1 request (or manipulate the .C register manually). See Writing Macros.

.do fam T

executes the fam request when compatibility mode is enabled.

gtroff restores the previous compatibility setting before interpreting any files sourced by the cmd.

Two other features are controlled by -C. If not in compatibility mode, GNU troff preserves the input level in delimited arguments:

.ds xx '
\w'abc\*(xxdef'

In compatibility mode, the string ‘72def'’ is returned; without -C the resulting string is ‘168’ (assuming a TTY output device).

Finally, the escapes \f, \H, \m, \M, \R, \s, and \S are transparent for recognizing the beginning of a line only in compatibility mode (this is a rather obscure feature). For example, the code

.de xx
Hallo!
..
\fB.xx\fP

prints ‘Hallo!’ in bold face if in compatibility mode, and ‘.xx’ in bold face otherwise.

GNU troff does not allow the use of the escape sequences \|, \^, \&, \{, \}, \SP, \', \`, \-, \_, \!, \%, and \c in names of strings, macros, diversions, number registers, fonts or environments; UNIX troff does. The \A escape sequence (see Identifiers) may be helpful in avoiding use of these escape sequences in names.

Fractional point sizes cause one noteworthy incompatibility. In UNIX troff the ps request ignores scale indicators and thus

.ps 10u

sets the point size to 10 points, whereas in GNU troff it sets the point size to 10 scaled points. See Fractional Type Sizes, for more information.

In GNU troff there is a fundamental difference between (unformatted) input characters and (formatted) output glyphs. Everything that affects how a glyph is output is stored with the glyph node; once a glyph node has been constructed it is unaffected by any subsequent requests that are executed, including bd, cs, tkf, tr, or fp requests. Normally glyphs are constructed from input characters at the moment immediately before the glyph is added to the current output line. Macros, diversions and strings are all, in fact, the same type of object; they contain lists of input characters and glyph nodes in any combination. A glyph node does not behave like an input character for the purposes of macro processing; it does not inherit any of the special properties that the input character from which it was constructed might have had. For example,

.di x
\\\\
.br
.di
.x

prints ‘\\’ in GNU troff; each pair of input backslashes is turned into one output backslash and the resulting output backslashes are not interpreted as escape characters when they are reread. UNIX troff would interpret them as escape characters when they were reread and would end up printing one ‘\’. The correct way to obtain a printable backslash is to use the \e escape sequence: This always prints a single instance of the current escape character, regardless of whether or not it is used in a diversion; it also works in both GNU troff and UNIX troff.28 To store, for some reason, an escape sequence in a diversion that is interpreted when the diversion is reread, either use the traditional \! transparent output facility, or, if this is unsuitable, the new \? escape sequence.

See Diversions, and Gtroff Internals, for more information.


Previous: , Up: gtroff Reference   [Contents][Index]