🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.text
Article #444

MS Macros/ME macros/MAN macros TROFF Universal Diversion Bug

#444
From: idallen
Date: Thu, 28 Feb 1985 00:25
71 lines
4448 bytes
Try to format the following text in a filled diversion (e.g. a footnote,
abstract, or keep) in any of your favourite macro packages.  I will use
the Footnote macros of -ms here as an example:

.LP
Start test.
.FS
x .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm
x .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm
x .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm
x .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm
x .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm
x .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm
x .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm
x .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm
x .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm
x .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm
.FE
End test.

For those unable to get to their computers, I'll explain what you get.

".tm" is the "type message" macro in TROFF.  When it appears at the
start of a line, the remainder of the line is sent to the standard
error output unit (not to the regular output stream).  Now, you will
note that no line above begins with ".tm", so you should expect that
nothing should appear on the error output stream.  This is not the case.

The text above is being collected in a filled diversion.  That means
that the words are shuffled around and "formatted" into an internal
buffer.  Depending on the current line length, the format of the text
in that internal buffer looks something like this:

    x .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm
    .tm .tm .tm x .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm
    .tm .tm .tm .tm .tm .tm x .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm
    .tm .tm .tm .tm .tm .tm .tm .tm .tm x .tm .tm .tm .tm .tm .tm .tm
    .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm x .tm .tm .tm .tm
    .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm x .tm
    .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm  .tm  .tm
    .tm .tm x .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm
    .tm .tm .tm .tm .tm x .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm
    .tm .tm .tm .tm .tm .tm .tm .tm x .tm .tm .tm .tm .tm .tm .tm .tm
    .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm x .tm .tm .tm .tm .tm
    .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm .tm

You can tell what's coming next, right?  How does TROFF put that
internal buffer into the normal input stream?  As a macro call.
And what is in the macro?  A whole bunch of lines that start with ".tm".
They execute.  In the above example, only one line gets put into the
real text and the rest spill out onto your error output unit because
of the executing ".tm" macro.

Now, consider what happens if, instead of ".tm", you had some other
word that began with a dot, such as ".login".  Since ".lo" isn't a
valid TROFF command, it ignores the line.  You get nothing.  No error.
No output.  No explanation.

To crown this disaster, replace all the ".tm" words with the
single-quoted string "'boo'".  Surprise!  The single-quote character
is also a control character to invoke a macro!  So you call the "'bo"
macro; no error message; no output; no explanation.

Fix: Unless you can get your local TROFF hack to change the macros,
you'd better not start any words in filled diversions with periods or
single quote characters.  It may \&'look a bit odd' to have these
silly empty \&'guard characters' in your running text, especially when
you talk about a \&.profile or \&.login file, or the \&.FS or \&.FE
macros, but you're used to these strange things on UNIX, aren't you?
-- 
        -IAN!  (Ian! D. Allen)      University of Waterloo
Technical Details
Message-ID: <11697@watmath.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!idallen

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site watmath.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!idallen
From: idallen@watmath.UUCP
Newsgroups: net.text,net.bugs.4bsd
Subject: MS Macros/ME macros/MAN macros TROFF Universal Diversion Bug
Message-ID: <11697@watmath.UUCP>
Date: Wed, 27-Feb-85 19:25:26 EST
Article-I.D.: watmath.11697
Posted: Wed Feb 27 19:25:26 1985
Date-Received: Fri, 1-Mar-85 05:09:22 EST
Distribution: net
Organization: U of Waterloo, Ontario
Lines: 71