[net.bugs.usg] Bug in S3 "nroff" and "-me" macros

guy@rlgvax.UUCP (Guy Harris) (12/23/83)

There is a bug in the System III "nroff" which causes the Berkeley "-me"
macros not to work (the bug seems to be fixed in the System V "nroff").
If you write something like:

	.if <condition> \
	.	do something

the V7 "nroff" accepted this (i.e., the "do something" was done only if the
<condition> was true) but the S3 "nroff" did the "do something" regardless.
The reason was that the code for ".if" that skips over text was redone in
S3 so that the text would be gobbled with "getch0()" (which doesn't do much
except read characters) as opposed to "getch()" (which expands number registers,
including autoincrement/decrement, etc. which means that you get screwed
if you really expected the autoincrement/decrement not to occur if the
condition was false).  (This fix is mentioned in the addendum to the "nroff"
manual in the S3 documentation.)  Unfortunately, using "getch0()" also turns
off the handling of "\<new-line>", so it eats the "\" at the end of the line
and stops.  The fix is to change the lines in "eatblk" in n5.c that read:

		if (i == ESC) cnt++;
		    else if (cnt == 1)
			     if (i == '{') i = LEFT;
				 else if (i == '}') i = RIGHT;
					  else cnt = 0;
			     else cnt = 0;

to:

		if (i == ESC) cnt++;
		    else if (cnt == 1)	{
			     if (i == '{') i = LEFT;
				 else if (i == '}') i = RIGHT;
					  else if (i == '\n') i = 0;
			     cnt = 0;	}

which also fixes a problem where "cnt" was left non-zero after a \{ or a
\} was seen.

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy