gbranden pushed a commit to branch master
in repository groff.

commit 732b07d4998bec1cc942481e7cf4e7287050c40b
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun May 18 10:07:35 2025 -0500

    [man]: Fix Savannah #65190 (1/2).
    
    Refactor continuous rendering mode to use an "infinite page length"
    method facilated by the new semantics of the `.R` register.
    
    * tmac/an.tmac (an-ne): Drop unneeded macro.
    
      (an-bp): Rename this...
      (an*bp): ...to this, define it with `de1` to temporary disable
      compatibility mode, and replace definition.  No longer altering
      the page length, it works like `br`, including
      control-character-sensitive behavior.
    
      (an-end): If continously rendering, stop incrementing the page length
      prior to writing the footer and document separation line, and upon
      encountering the end of the last document (the input file name
      register `.F` becomes empty), set the page length to the vertical
      drawing position.
    
      (an-end, TH): Call `an*break-page-with-new-number` only if _not_
      continuously rendering.
    
      (an-set-up-continuous-rendering): Drop macro in favor of open-coded
      initialization logic.
    
      (PT, BT): Stop manipulating the page length when continuously
      rendering.
    
      ([initialization]): If continuously rendering, set up replacement
      macro for `bp` request and set the page length to "infinite".
    
    Fixes Savannah #65190 (1/2).
---
 ChangeLog    | 29 ++++++++++++++++++++++++++
 tmac/an.tmac | 67 ++++++++++++++++--------------------------------------------
 2 files changed, 47 insertions(+), 49 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5264aec19..7a731473d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2025-05-18  G. Branden Robinson <[email protected]>
+
+       [man]: Refactor continuous rendering mode to use an "infinite
+       page length" method facilated by the new semantics of the `.R`
+       register.
+
+       * tmac/an.tmac (an-ne): Drop unneeded macro.
+       (an-bp): Rename this...
+       (an*bp): ...to this, define it with `de1` to temporary disable
+       compatibility mode, and replace definition.  No longer altering
+       the page length, it works like `br`, including
+       control-character-sensitive behavior.
+       (an-end): If continously rendering, stop incrementing the page
+       length prior to writing the footer and document separation line,
+       and upon encountering the end of the last document (the input
+       file name register `.F` becomes empty), set the page length to
+       the vertical drawing position.
+       (an-end, TH): Call `an*break-page-with-new-number` only if _not_
+       continuously rendering.
+       (an-set-up-continuous-rendering): Drop macro in favor of
+       open-coded initialization logic.
+       (PT, BT): Stop manipulating the page length when continuously
+       rendering.
+       ([initialization]): If continuously rendering, set up
+       replacement macro for `bp` request and set the page length to
+       "infinite".
+
+       Fixes Savannah #65190 (1/2).
+
 2025-05-17  G. Branden Robinson <[email protected]>
 
        [troff]: Improve warning diagnostics.
diff --git a/tmac/an.tmac b/tmac/an.tmac
index d32f41422..42d8d7a03 100644
--- a/tmac/an.tmac
+++ b/tmac/an.tmac
@@ -86,22 +86,8 @@
 .  nop \h'\\n[lss]u'\c
 ..
 .
-.\" Define alternate requests to handle continuous rendering.
-.\"
-.\" This .ne replacement avoids page breaks; instead, the page length is
-.\" increased to the necessary amount.
-.de an-ne
-.  ie \\n[.$] .nr an-amount (v;\\$*)
-.  el         .nr an-amount 1v
-.  if (\\n[an-amount] >= \\n[.t]) \
-.    pl +(\\n[an-amount]u - \\n[.t]u + 1v)
-.  rr an-amount
-..
-.
-.\" This .bp replacement for continuous rendering mode adjusts the page
-.\" length to the current position so that no empty lines are inserted.
-.de an-bp
-.  pl \\n[nl]u
+.de1 an*bp
+.  if \\n[.br] .br
 ..
 .
 .\" We need an end-of-input macro to flush any pending output line and
@@ -113,21 +99,11 @@
 .  an-input-trap
 .  if '\\n[.z]'an*paragraph-tag' .an*TP-trap
 .  if \\n[cR] \{\
-.    \" We might have a pending output line that is not yet broken, and
-.    \" also be 1v from the bottom of the page.  If we break (or flush)
-.    \" the output line now, the page will get ejected afterward and
-.    \" troff will exit because we're in an end-of-input macro--our
-.    \" footer will never be output.  So, if that is the case, further
-.    \" extend the page length by 1v.
-.    if ((\\n[.p] - \\n[nl]) <= \\n[.V]) .pl +1v
-.    br
-.    pl +1v
 .    sp 1v
 .    an-footer
 .    \" If we're processing multiple documents and have started a new
 .    \" one, draw a line between this footer and the next header.
 .    if !'\\n[.F]'' \{\
-.      pl +1v
 .      nf
 .      ti 0
 .      nr an*rule-length (\\n[LL]u - 1n)
@@ -139,15 +115,11 @@
 .  rr an-TH-was-called
 .  ds an*previous-page-ref-string \" empty
 .  ch an-header
-.  an*break-page-with-new-number
-..
-.
-.\" Move macros into place for continuous rendering.
-.de an-set-up-continuous-rendering
-.  rn ne an-real-ne
-.  rn bp an-real-bp
-.  rn an-ne ne
-.  rn an-bp bp
+.  \" At the end of the last document, the file name becomes empty;
+.  \" force the page length to match the vertical drawing position in
+.  \" continuous rendering mode.
+.  ie \\n[cR] .if '\\n[.F]'' .pl \\n[nl]u
+.  el         .an*break-page-with-new-number
 ..
 .
 .de an*reset-hyphenation-mode
@@ -256,7 +228,7 @@
 .    \" Clear the page header trap so it is not sprung with stale
 .    \" information.
 .    ch an-header
-.    an*break-page-with-new-number
+.    if !\\n[cR] .an*break-page-with-new-number
 .  \}
 .  if \\n[C] .rr P
 .
@@ -438,13 +410,9 @@
 ..
 .
 .\" Write the page header; can be redefined by man.local.
-.\"
-.\" In continuous rendering mode, we need to extend the page length to
-.\" accommodate the vertical size of our header (plus any spacing).
 .if d PT .ig
 .de1 PT
-.  ie \\n[cR] .pl +1v
-.  el         .sp (.5i - .5m)
+.  if !\\n[cR] .sp (.5i - .5m)
 .  \" Attach a bookmark to the page header on the first page of a new
 .  \" man(7) document; a changed identifier or section indicates this.
 .  if !'\\*[an*page-ref-string]'\\*[an*previous-page-ref-string]' \{\
@@ -453,11 +421,8 @@
 .    ds an*previous-page-ref-string "\\*[an*page-ref-string]
 .  \}
 .  tl '\\*[an-pageref]'\\*[an-extra3]'\\*[an-pageref]'
-.  ie \\n[cR] \{\
-.    pl +1v
-.    sp 1v
-.  \}
-.  el .sp .5i
+.  ie \\n[cR] .sp 1v
+.  el         .sp .5i
 ..
 .
 .\" Write the page footer; can be redefined by man.local.
@@ -466,7 +431,6 @@
 .\" accommodate the vertical size of our footer (plus any spacing).
 .if d BT .ig
 .de1 BT
-.  if \\n[cR] .pl +1v
 .  ie \\n[D] \{\
 .    if o .tl '\\*[an*ifoot]'\\*[an-extra1]'\\*[an*ofoot]'
 .    if e .tl '\\*[an*ofoot]'\\*[an-extra1]'\\*[an*ifoot]'
@@ -1731,8 +1695,13 @@ contains unsupported escape sequence
 .\}
 .rm an*ident-style
 .
-.if \n[cR] \
-.  an-set-up-continuous-rendering
+.\" In continuous rendering mode, make page breaks less potent and the
+.\" page length "infinite".
+.if \n[cR] \{\
+.  rn bp an*real-bp
+.  rn an*bp bp
+.  pl \n[.R]u/1v
+.\}
 .
 .\" If rendering HTML, suppress headers and footers.
 .nr an-suppress-header-and-footer 0

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to