gbranden pushed a commit to branch master in repository groff. commit a00682e9cb4070e35139f6df59130d9ce12505ce Author: G. Branden Robinson <g.branden.robin...@gmail.com> AuthorDate: Thu Jul 25 15:20:55 2024 -0500
[troff]: Enforce minimum page length. * src/roff/troff/div.cpp (page_length): Clamp `pl` request argument to the output device's vertical resolution (similarly to the way `ll` and `lt` behave). * doc/groff.texi.in (Page Layout): * NEWS: Document this. --- ChangeLog | 11 +++++++++++ NEWS | 5 +++++ doc/groff.texi.in | 12 ++++++------ src/roff/troff/div.cpp | 13 ++++++++++--- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 79882167f..a20737e48 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2024-07-25 G. Branden Robinson <g.branden.robin...@gmail.com> + + [troff]: Enforce minimum page length. + + * src/roff/troff/div.cpp (page_length): Clamp `pl` request + argument to the output device's vertical resolution (similarly + to the way `ll` and `lt` behave). + + * doc/groff.texi.in (Page Layout): + * NEWS: Document this. + 2024-07-25 G. Branden Robinson <g.branden.robin...@gmail.com> * src/roff/troff/env.cpp (line_length, title_length): Drop use diff --git a/NEWS b/NEWS index 90a1646ad..c89f4b55b 100644 --- a/NEWS +++ b/NEWS @@ -22,6 +22,11 @@ o The `mso` request no longer attempts to open a macro file named, say, simply processes the macro search path for a file name matching the request argument, and succeeds or fails depending on an exact match. +o GNU troff no longer accepts nonpositive page lengths. Attempting to + set one with the `pl` request clamps the page length to the vertical + motion quantum as `ll` does with the horizontal motion quantum in AT&T + and GNU troffs. + o The `color`, `cp`, `linetabs`, and `vpt` requests now interpret arguments with negative values as instructions to disable the corresponding feature, using the *roff integer-to-Boolean conversion diff --git a/doc/groff.texi.in b/doc/groff.texi.in index 18aff8d8c..1ea82341d 100644 --- a/doc/groff.texi.in +++ b/doc/groff.texi.in @@ -10096,12 +10096,12 @@ The formatter permits configuration of the page length and page number. @cindex configuring the page length (@code{pl}) @cindex setting the page length (@code{pl}) Change (increase or decrease) the page length per the numeric expression -@var{length}. The default scaling unit is @samp{v}. A negative -@var{length} is valid, but an uncommon application:@: it prevents page -location traps from being sprung,@footnote{@xref{Traps}.} and each -output line is placed on a new page. If @var{length} is invalid, GNU -@code{troff} emits a warning in category @samp{number}. If @var{length} -is absent or invalid, @samp{11i} is assumed. +@var{length}. The default scaling unit is @samp{v}. If @var{length} is +invalid, GNU @code{troff} emits a warning in category @samp{number}. If +@var{length} is absent or invalid, @samp{11i} is assumed. If +@var{length} is nonpositive, GNU @command{troff} emits a warning in +category @samp{range} and sets the page length to the device's vertical +motion quantum; recall @ref{Motion Quanta}. @cindex page length register (@code{.p}) The read-only register @samp{.p} interpolates the current page length. diff --git a/src/roff/troff/div.cpp b/src/roff/troff/div.cpp index 83f10e7bc..5b352a315 100644 --- a/src/roff/troff/div.cpp +++ b/src/roff/troff/div.cpp @@ -701,9 +701,16 @@ void page_offset() void page_length() { - vunits n; - if (has_arg() && get_vunits(&n, 'v', topdiv->get_page_length())) - topdiv->set_page_length(n); + vunits temp; + if (has_arg() && get_vunits(&temp, 'v', topdiv->get_page_length())) { + if (temp < vresolution) { + warning(WARN_RANGE, "setting invalid page length %1u to device" + " vertical motion quantum", + temp.to_units()); + temp = vresolution; + } + topdiv->set_page_length(temp); + } else topdiv->set_page_length(11*units_per_inch); skip_line(); _______________________________________________ Groff-commit mailing list Groff-commit@gnu.org https://lists.gnu.org/mailman/listinfo/groff-commit