gbranden pushed a commit to branch master
in repository groff.
commit cbb1afae69f85cbdf4e44202ad84f8e9f8cc37b8
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sat Oct 4 10:46:16 2025 -0500
[man]: Handle degenerate documents more robustly.
If given formattable input text with no macro calls, and continuously
rendering, don't put 1.3 million blank lines (`\n[.R]/1v`) on the
output.
* tmac/an.tmac ([initialization]): Initialize registers and strings
accessed by trap-called macros, since the end of input springs several
of them.
(TH): Move end-of-input macro setup from here...
([initialization]): ...to here.
(TH): We now no longer need the `an-TH-was-called` register, so
stop creating it...
(an*end-document): ...stop removing it, and stop checking its
existence. Also, when continuously rendering, update the page
length immediately after writing the footer, just as our mdoc(7)
package does.
---
ChangeLog | 19 +++++++++++++++++++
tmac/an.tmac | 17 ++++++++++++-----
2 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 50f998c50..0b55d40c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,25 @@
Thanks to Grisha Levit for report of problem with some pdf
viewers.
+2025-10-04 G. Branden Robinson <[email protected]>
+
+ [man]: Handle degenerate documents more robustly; if given
+ formattable input text with no macro calls, and continuously
+ rendering, don't put 1.3 million blank lines (`\n[.R]/1v`) on
+ the output.
+
+ * tmac/an.tmac ([initialization]): Initialize registers and
+ strings accessed by trap-called macros, since the end of input
+ springs several of them.
+ (TH): Move end-of-input macro setup from here...
+ ([initialization]): ...to here.
+ (TH): We now no longer need the `an-TH-was-called` register, so
+ stop creating it...
+ (an*end-document): ...stop removing it, and stop checking its
+ existence. Also, when continuously rendering, update the page
+ length immediately after writing the footer, just as our mdoc(7)
+ package does.
+
2025-10-04 G. Branden Robinson <[email protected]>
[man]: Regression-test continuously rendered degenerate output;
diff --git a/tmac/an.tmac b/tmac/an.tmac
index 60585c8ea..8d9045207 100644
--- a/tmac/an.tmac
+++ b/tmac/an.tmac
@@ -96,7 +96,6 @@
.\" called by andoc when switching to an mdoc(7) page, irrespective of
.\" continuous rendering mode.
.de1 an*end-document
-. if !r an-TH-was-called .return
. an*input-trap
. if '\\n[.z]'an*paragraph-tag' .an*TP-trap
. if \\n[cR] \{\
@@ -112,8 +111,9 @@
. rr an*rule-length
. fi
. \}
+. \" suppress empty lines after the footer
+. pl \n[nl]u
. \}
-. rr an-TH-was-called
. ds an*previous-page-ref-string \" empty
. ch an-header
. \" At the end of the last document, the file name becomes empty;
@@ -337,8 +337,6 @@
. \}
. if \\n[C] .rr P
.
-. nr an-TH-was-called 1 \" an*end-document can make certain assumptions.
-.
. \" The previous document rendered in a batch may have been in a
. \" different language.
. if '\\*[locale]'english' .an*localize-strings
@@ -437,7 +435,6 @@
. \}
. \}
.
-. em an*end-document
. nr an*need-titles-reset 1
..
.
@@ -1481,6 +1478,14 @@ contains unsupported escape sequence
.\" page.
.nr an*need-titles-reset 0
.
+.\" Initialize registers and strings that trap-called macros access, to
+.\" avoid warnings when formatting degenerate man(7) documents.
+.nr an-need-no-space-mode 0
+.nr an-need-break 0
+.ds an-pageref \" empty
+.ds an*ifoot \" empty
+.ds an-extra1 \" empty
+.
.\" We don't have to worry about "xhtml" (it's mapped to "html"), but we
.\" do need to account for pre-grohtml(1)'s use of "groff -Tps".
.nr an*is-output-html 0
@@ -1787,6 +1792,8 @@ contains unsupported escape sequence
.nr an-suppress-header-and-footer 0
.if \n[an*is-output-html] .nr an-suppress-header-and-footer 1
.
+.em an*end-document
+.
.cp \n[*groff_an_tmac_C]
.do rr *groff_an_tmac_C
.
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit