Guidebook: Improve package loading for groff 1.24

groff 1.24 is in its second release candidate of this writing and
features a noteworthy revision to its syntax.

---snip---
NEWS:
*  If your roff(7) documents follow any of the requests ... `so`, ...
   with a comment after their file name argument, and did not place that
   comment immediately after the file name, you are likely to get a
   diagnostic message resembling the following.

    warning: cannot open macro file 'e.tmac ': No such file or directory

   Or, less likely, the formatter will open the wrong file, one with
   spaces at the end of its name.  That is because these requests are
   now able to process file names containing space characters.  (This
   change also makes the request syntax consistent with that of `ds`,
   `as`, and others.)  A quick fix is to place the comment escape
   sequence as early as possible.  For example, we would change:

     .mso e.tmac \" Load Eric Allman's package.

   to:

     .mso e.tmac\" Load Eric Allman's package.

   to tell the formatter to load the "e.tmac" file rather than
   "e.tmac ".  See the items below for further details.
---end snip---

Work around this change while maintaining with older groff and other
*roff formatters.

1.  Stop using space to separate comments from the argument to `so`.
2.  Temporarily define a `So` macro to wrap the `soquiet` request (for
    groff 1.23 and later) or `so` request (for everything else).
3.  Abort formatting with an error diagnostic if the `nh` macro package
    the Guidebook requires cannot be located.

Fixes:
$ (cd doc && rm -f Guidebook && make Guidebook)
troff:<standard input>:34: error: cannot open 'tmac.nh ': No such file or directory
troff:<standard input>:35: error: cannot open 'doc/tmac.nh': No such file or directory
This commit is contained in:
G. Branden Robinson
2026-02-06 09:02:42 -06:00
parent 6a8edddcb9
commit b4bd6fb2b8

View File

@@ -31,8 +31,21 @@
.lt 70n
.\}
.
.so tmac.nh \" extra macros which aren't in tmac.n
.if !\n(nH .so doc/tmac.nh
.\" Load extra macros that "tmac.n" doesn't define.
.de So
.ie \n(.g&(\n(.x=1)&(\n(.y>22) .soquiet \\$1
.el .so \\$1
..
.
.So tmac.nh
.if !\n(nH So doc/tmac.nh
.
.if !\n(nH \{\
.tm fatal error: cannot locate "tmac.nh" macro package
.ab
.\}
.
.rm So
.
.\" building Guidebook.txt doesn't have CR font available; groff 1.23 issues
.\" a warning each time any font can't be loaded; earlier versions silently