gbranden pushed a commit to branch master
in repository groff.

commit 0b1f30648d77b3ea76364495d3db088c8c6b5201
Author: G. Branden Robinson <[email protected]>
AuthorDate: Tue Oct 21 15:02:21 2025 -0500

    [gropdf]: Make pdfmom able to run a build's groff.
    
    * src/devices/gropdf/pdfmom.pl: Add new global scalar `groff` to store
      the name/locate of the groff command to run.  Default its value to
      "groff", but override it with the contents of the environment variable
      `GROFF_COMMAND` if that exists.  Update hard-coded "groff" literals
      with interpolations of this scalar.  This interface is deliberately
      not documented in the man page, since it's intended for the use of
      groff's build system.
---
 ChangeLog                    | 12 ++++++++++++
 src/devices/gropdf/pdfmom.pl | 16 +++++++++-------
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ca5c630fb..c501d518d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2025-10-21  G. Branden Robinson <[email protected]>
+
+       [gropdf]: Make pdfmom able to run the build tree's groff.
+
+       * src/devices/gropdf/pdfmom.pl: Add new global scalar `groff` to
+       store the name/locate of the groff command to run.  Default its
+       value to "groff", but override it with the contents of the
+       environment variable `GROFF_COMMAND` if that exists.  Update
+       hard-coded "groff" literals with interpolations of this scalar.
+       This interface is deliberately not documented in the man page,
+       since it's intended for the use of groff's build system.
+
 2025-10-21  G. Branden Robinson <[email protected]>
 
        [gropdf]: Make pdfmom disclose version of groff it runs.
diff --git a/src/devices/gropdf/pdfmom.pl b/src/devices/gropdf/pdfmom.pl
index 6301947e8..172305c0d 100644
--- a/src/devices/gropdf/pdfmom.pl
+++ b/src/devices/gropdf/pdfmom.pl
@@ -29,6 +29,7 @@ use File::Temp qw/tempfile/;
 
 my @cmd;
 my $dev='pdf';
+my $groff='groff';
 my $preconv='';
 my $readstdin=1;
 my $mom='-mom';
@@ -49,6 +50,7 @@ my $RT_SEP='@RT_SEP@';
 
 $ENV{PATH}=$ENV{GROFF_BIN_PATH}.$RT_SEP.$ENV{PATH} if 
exists($ENV{GROFF_BIN_PATH});
 $ENV{TMPDIR}=$ENV{GROFF_TMPDIR} if exists($ENV{GROFF_TMPDIR});
+$groff=$ENV{GROFF_COMMAND} if exists ($ENV{GROFF_COMMAND});
 
 (undef,undef,my $prog)=File::Spec->splitpath($0);
 
@@ -68,11 +70,11 @@ sub autopsy
        $finding = "unable to run groff: $!\n";
     }
     elsif ($? & 127) {
-       $finding = sprintf("groff died with signal %d, %s core dump\n",
+       $finding = sprintf("$groff died with signal %d, %s core dump\n",
            ($? & 127),  ($? & 128) ? 'with' : 'without');
     }
     else {
-       $finding = sprintf("groff exited with status %d\n", $? >> 8);
+       $finding = sprintf("$groff exited with status %d\n", $? >> 8);
     }
 
     return $finding;
@@ -140,7 +142,7 @@ while (my $c=shift)
     elsif ($c eq '-v' or $c eq '--version')
     {
        print "GNU pdfmom (groff) version @VERSION@\n";
-       my $waitstatus = system("groff -T$dev --version");
+       my $waitstatus = system("$groff -T$dev --version");
        abort(autopsy($?)) unless $waitstatus == 0;
        exit;
     }
@@ -193,24 +195,24 @@ if ($dev eq 'pdf')
 {
     if ($mom)
     {
-       $waitstatus = system("groff -Tpdf -dLABEL.REFS=1 $mom -z $cmdstring 
2>&1 | LC_ALL=C grep '^\\. *ds' | groff -Tpdf $preconv -dPDF.EXPORT=1 
-dLABEL.REFS=1 $mom -z - $cmdstring 2>&1 | LC_ALL=C grep '^\\. *ds' | groff 
-Tpdf $mom $preconv - $cmdstring $zflg");
+       $waitstatus = system("$groff -Tpdf -dLABEL.REFS=1 $mom -z $cmdstring 
2>&1 | LC_ALL=C grep '^\\. *ds' | $groff -Tpdf $preconv -dPDF.EXPORT=1 
-dLABEL.REFS=1 $mom -z - $cmdstring 2>&1 | LC_ALL=C grep '^\\. *ds' | $groff 
-Tpdf $mom $preconv - $cmdstring $zflg");
        abort(autopsy($?)) unless $waitstatus == 0;
 
     }
     else
     {
-       $waitstatus = system("groff -Tpdf $preconv -dPDF.EXPORT=1 -z $cmdstring 
2>&1 | LC_ALL=C grep '^\\. *ds' | groff -Tpdf $preconv - $cmdstring $zflg");
+       $waitstatus = system("$groff -Tpdf $preconv -dPDF.EXPORT=1 -z 
$cmdstring 2>&1 | LC_ALL=C grep '^\\. *ds' | $groff -Tpdf $preconv - $cmdstring 
$zflg");
        abort(autopsy($?)) unless $waitstatus == 0;
     }
 }
 elsif ($dev eq 'ps')
 {
-       $waitstatus = system("groff -Tpdf -dLABEL.REFS=1 $mom -z $cmdstring 
2>&1 | LC_ALL=C grep '^\\. *ds' | pdfroff -mpdfmark $mom --no-toc - $preconv 
$cmdstring");
+       $waitstatus = system("$groff -Tpdf -dLABEL.REFS=1 $mom -z $cmdstring 
2>&1 | LC_ALL=C grep '^\\. *ds' | pdfroff -mpdfmark $mom --no-toc - $preconv 
$cmdstring");
        abort(autopsy($?)) unless $waitstatus == 0;
 }
 elsif ($dev eq '-z') # pseudo dev - just compile for warnings
 {
-    $waitstatus = system("groff -Tpdf $mom -z $cmdstring");
+    $waitstatus = system("$groff -Tpdf $mom -z $cmdstring");
     abort(autopsy($?)) unless $waitstatus == 0;
 }
 else

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

Reply via email to