On Saturday, 9 December 2023 19:25:27 GMT G. Branden Robinson wrote: > At 2023-12-09T09:26:16-0500, Douglas McIlroy wrote: > > > For historical reasons (and for compatibility with AT&T 'troff'), > > > the end macro exits as soon as it causes a page break and > > > no remaining data is in the partially collected line. > > > > This isn't the only anomalous behavior at the end of a document. Since > > day one, troff has occasionally emitted a blank page at the end. I > > believe this is because a new page is triggered when the previous page > > is filled rather than when some output needs somewhere to go. A > > document that exactly fills the last page thus gets an extra page. > > Right. When a line of output is "finished" and sent to the device > (device-independent output is prepared for it), the vertical position > advances by one vee, and, (in groff, if vertical position traps are not > disabled,) any visible vertical position traps planted between the > previous text baseline and the new one are sprung.[1] If one of these > traps is what I term "the implicit page trap"[2], then the page is > ejected and a new one started.
Is this the problem? It does not make sense to start a new page until groff "knows" there will be further output. So if the implicit page trap is triggered it should set a flag to trigger the new page code if further output, other than "x trailer", is output. This is an example of troff output:- x T pdf x res 72000 1 1 x init p1 x font 5 TR f5 s10000 V12000 H72000 mr 0 0 0 DFd tline n12000 0 V792000 H72000 tline n12000 0 V792000 p2 x trailer V792000 x stop The V792000 and p2 are unnecessary unless there is further output. Cheers Deri