gbranden pushed a commit to branch master
in repository groff.

commit e44babb1db3919a6386145531623017d1218e84f
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Oct 28 18:53:59 2026 -0500

    [mm]: Align `mmroff` with `pdfmom`.
    
    * contrib/mm/mmroff.pl: Adopt pdfmom(1)'s method of locating the groff
      executable, employing the undocumented `GROFF_COMMAND` environment
      variable so we can point mmroff at "test-groff" when building groff
      and using "make check" or "make distcheck".  The previous method was
      not reliable when building from Git in the source tree.  Set up
      `groff` scalar early, override its value with that of `GROFF_COMMAND`
      if defined, stop manually searching `GROFF_BIN_PATH` for it (since
      `GROFF_COMMAND` is expected to contain a resolvable file name), and do
      not hard-code "groff" as a fall back if the search fails.
    
    * contrib/mm/tests/GETST-works.sh:
    * contrib/mm/tests/mmroff-does-not-defeat-safer-mode.sh: Define a new
      `groff` top-of-script variable, and later put it into the environment
      as `GROFF_COMMAND`.
---
 contrib/mm/ChangeLog                                  | 17 +++++++++++++++++
 contrib/mm/mmroff.pl                                  | 19 +++----------------
 contrib/mm/tests/GETST-works.sh                       |  2 ++
 contrib/mm/tests/mmroff-does-not-defeat-safer-mode.sh |  2 ++
 4 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/contrib/mm/ChangeLog b/contrib/mm/ChangeLog
index 719a387ce..4e736aa36 100644
--- a/contrib/mm/ChangeLog
+++ b/contrib/mm/ChangeLog
@@ -1,3 +1,20 @@
+2026-10-28  G. Branden Robinson <[email protected]>
+
+       * mmroff.pl: Adopt pdfmom(1)'s method of locating the groff
+       executable, employing the undocumented `GROFF_COMMAND`
+       environment variable so we can point mmroff at "test-groff" when
+       building groff and using "make check" or "make distcheck".  The
+       previous method was not reliable when building from Git in the
+       source tree.  Set up `groff` scalar early, override its value
+       with that of `GROFF_COMMAND` if defined, stop manually searching
+       `GROFF_BIN_PATH` for it (since `GROFF_COMMAND` is expected to
+       contain a resolvable file name), and do not hard-code "groff" as
+       a fall back if the search fails.
+       * tests/GETST-works.sh:
+       * tests/mmroff-does-not-defeat-safer-mode.sh: Define a new
+       `groff` top-of-script variable, and later put it into the
+       environment as `GROFF_COMMAND`.
+
 2026-10-28  G. Branden Robinson <[email protected]>
 
        * tests/mmroff-does-not-defeat-safer-mode.sh: Set up environment
diff --git a/contrib/mm/mmroff.pl b/contrib/mm/mmroff.pl
index a258b4ff1..a38615ed3 100644
--- a/contrib/mm/mmroff.pl
+++ b/contrib/mm/mmroff.pl
@@ -30,7 +30,9 @@ use Config;
 
 (my $progname = $0) =~s @.*/@@;
 
-my $groff; # forward declaration for `autopsy`
+# Locate groff executable.
+my $groff = "groff";
+$groff=$ENV{GROFF_COMMAND} if exists ($ENV{GROFF_COMMAND});
 
 sub abort
 {
@@ -93,21 +95,6 @@ if (grep(/^-x$/, @ARGV)) {
        @ARGV = grep(!/^-x$/, @ARGV);
 }
 
-# Locate groff executable.
-my $path = $ENV{'GROFF_BIN_PATH'};
-
-if ($path) {
-       for my $dir (split($Config{path_sep}, $path)) {
-               my $candidate = "$dir/groff";
-               if (-x $candidate) {
-                       $groff = $candidate;
-                       last;
-               }
-       }
-}
-
-$groff = "groff" if (!$groff);
-
 # mmroff should always have -mm, but not twice
 @ARGV = grep(!/^-mm$/, @ARGV);
 my $first_pass = "$groff -rRef=1 -z -mm @ARGV";
diff --git a/contrib/mm/tests/GETST-works.sh b/contrib/mm/tests/GETST-works.sh
index b06486484..7d93e5a6b 100755
--- a/contrib/mm/tests/GETST-works.sh
+++ b/contrib/mm/tests/GETST-works.sh
@@ -19,6 +19,7 @@
 # along with this program. If not, see <http://www.gnu.org/licenses/>.
 
 mmroff="${abs_top_builddir:-.}/mmroff"
+groff="${abs_top_builddir:-.}/test-groff"
 fontdir="${abs_top_builddir:-.}/font"
 src="${abs_top_srcdir:-..}"
 
@@ -55,6 +56,7 @@ mmdir=$src/contrib/mm/
 
 GROFF_BIN_PATH=. GROFF_FONT_PATH="$fontdir":"$src"/font \
     GROFF_TMAC_PATH="$src"/contrib/mm:"$src"/tmac \
+    GROFF_COMMAND="$groff" \
     "$mmroff" -t -T utf8 -P -cbou "$artifacts_dir"/use-reference.mm \
     | grep -q 'Use Table 1 to'
 status=$?
diff --git a/contrib/mm/tests/mmroff-does-not-defeat-safer-mode.sh 
b/contrib/mm/tests/mmroff-does-not-defeat-safer-mode.sh
index ece513325..2dbaa70db 100755
--- a/contrib/mm/tests/mmroff-does-not-defeat-safer-mode.sh
+++ b/contrib/mm/tests/mmroff-does-not-defeat-safer-mode.sh
@@ -19,6 +19,7 @@
 # along with this program. If not, see <http://www.gnu.org/licenses/>.
 
 mmroff="${abs_top_builddir:-.}/mmroff"
+groff="${abs_top_builddir:-.}/test-groff"
 fontdir="${abs_top_builddir:-.}/font"
 src="${abs_top_srcdir:-..}"
 
@@ -44,6 +45,7 @@ input='.
 printf "%s\n" "$input" \
     | GROFF_BIN_PATH=. GROFF_FONT_PATH="$fontdir":"$src"/font \
         GROFF_TMAC_PATH="$src"/contrib/mm:"$src"/tmac \
+        GROFF_COMMAND="$groff" \
         "$mmroff"
 
 if ! test -f "$oops_file"

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

Reply via email to