titroff buf (and the bug appears in [ntv]roff as well!)

Jaap Akkerhuis jaap at mcvax.UUCP
Tue Jun 21 05:43:32 AEST 1983


	In titroff, if the first text or motion output comes from
	a .tl command, the begin-page command is omitted from the output.
	For example if you 'compile':
		.tl ###Right Adjusted#
		...
	you get something like:
		...
		x font 4 S
		H416
		f1
		s10
		V72
		h2402cR
		45i17g30h35t20 20A48d33j15u35s25t20e30dn72 0
		...
	It might be due to the 'newline(0)' call in 'casetl()'
	(line 778 in n3.c) but it might not, it's difficult to tell.
	Your bright ideas would be appreciated.

Yes, I know about the problem, and have a fix as well.
As a matter of fact, this bug doesn't only exists in titroff (some prefer to
say ditroff), it is an old bug in all the versions of [ntv]roff as well.
In [ntv]roff the effect is different, but quite similar.
If you start witl a .tl, nroff -o1 will never find page one.

The solution for the lazy ones:
	Just  do a .br as first line of your file.
	This makes the problem go away.

The reason why and the solution for it:
	It is not the newline(0), but you are close.

	The text produced by .tl is a special case of text, and this causes
	the problem if it is the first thing to be output.
	If *roff starts, v.nl is initialized to -1.
	If a break occurs or there is some text to be
	output, the lines
		if((dip == d) && (v.nl == -1)) {
			newline(1);
			return;
		}
	in text() or tbreak() (n7.c) are executed.
	The newline(1) will set v.nl to 0.
	This will result in some administration about the pagenumbers. 
	(and possibly dostop will be done)
	(And in titroff newpage(v.pn)is executed, resulting in the
	string "p1" be output).

	So one solution is to change the newline(0) in casetl() to a test
	on v.nl and call newline(1) if it happens to be < 0,
	in the style of the lines quoted above.

You might wonder why v.nl isn't initialized to 0.
Well, in [ntv]roff you will than get an empty page if you have a 
zero length iput file or input which doesn't produce output (f.i. a
file with only macros which doesn't produce output).
In titroff you might initialize it to 0.
With a zero length input file you get:
	...
	V4752 (or as long as your page is in your local goobies an inch)
	      (these are cat units).
	x stop
   (it won't do the p1, so your device filter doesn't need to do anything).
I guess, for the sake of compatability, it might wise to put the fix in.

I hope these suggestions are useful. There are more bugs in these programs
but as long as nobody complains, I don't want to send them out yet.
(It costs some time to do these kind of things).

It's time net.text or net.roffs is started, this is where this discussion
should take place. As you can see, bugs are most of the time in all
the *roffs, so net.[td]itroff might be an overkill.

jaap akkerhuis {decvax,philabs}!mcvax!jaap
		Mathematisch Centrum
		Kruislaan 413
		Amsterdam, The Netherlands.



More information about the Comp.unix.wizards mailing list