gbranden pushed a commit to branch master
in repository groff.

commit a914f9f64be51ec6bb43429695859a2036e75b58
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Aug 9 02:50:53 2024 -0500

    tmac/troffrc{,-end}: Help users avoid blunders.
    
    * tmac/troffrc: Define macro `troffrc*trap` to throw a diagnostic
      message complaining of a text line in a startup file.  Make it the
      blank line and leading space macro.
    * tmac/troffrc-end: Clear blank line and leading space macros.  Delete
      `troffrc*trap`.
    
    A text line in a startup file (1) causes the formatter to produce output
    even if given no input; and (2) can mess up the formatting of a document
    with content, such as by adding a blank line to the top of it
    unexpectedly.  It could also interfere with page header trap setup since
    the "initial" vertical drawing position (as perceived by an input
    document) is not "-1" (above the top of the page) as expected.
    
    This should also help us keep our own macro files clean.  See
    "src/roff/groff/tests/initialization_is_quiet.sh".
    
    Inspired by an Arch Linux blunder <https://gitlab.archlinux.org/
    archlinux/packaging/packages/groff/-/commit/
    db8623565d8e14d4c9c5c3a67e1c8647c34e3d48>.  I've made similar ones
    myself.
---
 ChangeLog        | 13 +++++++++++++
 tmac/troffrc     | 10 ++++++++++
 tmac/troffrc-end |  7 ++++++-
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 101205061..431675922 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2024-08-09  G. Branden Robinson <[email protected]>
+
+       * tmac/troffrc: Define macro `troffrc*trap` to throw a
+       diagnostic message complaining of a text line in a startup file.
+       Make it the blank line and leading space macro.
+       * tmac/troffrc-end: Clear blank line and leading space macros.
+       Delete `troffrc*trap`.
+
+       Inspired by an Arch Linux blunder <https://gitlab.archlinux.org/
+       archlinux/packaging/packages/groff/-/commit/
+       db8623565d8e14d4c9c5c3a67e1c8647c34e3d48>.  I've made similar
+       ones myself.
+
 2024-08-09  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/input.cpp (input_stack::get)
diff --git a/tmac/troffrc b/tmac/troffrc
index e42e821ce..fe1fee19f 100644
--- a/tmac/troffrc
+++ b/tmac/troffrc
@@ -1,10 +1,20 @@
 .\" startup file for GNU troff
 .\"
+.\" This file is interpreted before any macro files specified as -m
+.\" option arguments are read.
+.\"
 .\" Use .do for any groff extensions so that this file works with -C.
 .
 .\" This is tested by pic.
 .nr 0p 0
 .
+.do de troffrc*trap
+.  do tm troffrc:\\n[.F]:\\n[.c]: text line in startup file
+..
+.
+.do blm troffrc*trap
+.do lsm troffrc*trap
+.
 .\" Load composite mappings.
 .do mso composite.tmac
 .
diff --git a/tmac/troffrc-end b/tmac/troffrc-end
index cf31db61c..993d8b444 100644
--- a/tmac/troffrc-end
+++ b/tmac/troffrc-end
@@ -1,6 +1,7 @@
 .\" final startup file for GNU troff
 .\"
-.\" This file is parsed after all -m file arguments have been read.
+.\" This file is interpreted after all macro files specified as -m
+.\" option arguments have been read.
 .\"
 .\" Use .do for any groff extensions so that this file works with -C.
 .
@@ -27,6 +28,10 @@
 .do if !d EQN-HTML-DO-IMAGE      .do ds EQN-HTML-DO-IMAGE \" empty
 .do if !d EQN-HTML-IMAGE-END     .do ds EQN-HTML-IMAGE-END \" empty
 .
+.do blm
+.do lsm
+.do rm troffrc*trap
+.
 .\" Local Variables:
 .\" mode: nroff
 .\" fill-column: 72

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

Reply via email to