[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 33/126: [mm]: Make "mmroff" honor `GROFF_BIN_PATH`.
From: |
G. Branden Robinson |
Subject: |
[groff] 33/126: [mm]: Make "mmroff" honor `GROFF_BIN_PATH`. |
Date: |
Wed, 5 Jul 2023 17:02:48 -0400 (EDT) |
gbranden pushed a commit to branch branden-2023-07-05
in repository groff.
commit b9715639135e0978ada217251b82319d48f48bb5
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Tue Jul 4 11:40:01 2023 -0500
[mm]: Make "mmroff" honor `GROFF_BIN_PATH`.
* contrib/mm/mmroff.pl: Honor `GROFF_BIN_PATH` environment variable.
* contrib/mm/mmroff.1.man (Environment): Add section documenting this.
---
contrib/mm/ChangeLog | 5 +++++
contrib/mm/mmroff.1.man | 26 ++++++++++++++++++++++++++
contrib/mm/mmroff.pl | 24 +++++++++++++++++++++---
3 files changed, 52 insertions(+), 3 deletions(-)
diff --git a/contrib/mm/ChangeLog b/contrib/mm/ChangeLog
index db91d6063..5d9cc6cb6 100644
--- a/contrib/mm/ChangeLog
+++ b/contrib/mm/ChangeLog
@@ -1,3 +1,8 @@
+2023-07-04 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * mmroff.pl: Honor `GROFF_BIN_PATH` environment variable.
+ * mmroff.1.man (Environment): Add section documenting this.
+
2023-07-04 G. Branden Robinson <g.branden.robinson@gmail.com>
* mmroff.pl: Trivially refactor. Rename scalars.
diff --git a/contrib/mm/mmroff.1.man b/contrib/mm/mmroff.1.man
index 7920c709d..526edef63 100644
--- a/contrib/mm/mmroff.1.man
+++ b/contrib/mm/mmroff.1.man
@@ -134,6 +134,32 @@ Create or update the cross-reference file and exit.
.
.
.\" ====================================================================
+.SH Environment
+.\" ====================================================================
+.
+Normally,
+the path separator in environment variables ending with
+.I PATH
+is the colon;
+this may vary depending on the operating system.
+.
+For example,
+Windows uses a semicolon instead.
+.
+.
+.TP
+.I GROFF_BIN_PATH
+is a colon-separated list of directories in which to search for the
+.I groff
+executable before searching in
+.IR PATH .
+.
+If unset,
+.I @BINDIR@
+is used.
+.
+.
+.\" ====================================================================
.SH Authors
.\" ====================================================================
.
diff --git a/contrib/mm/mmroff.pl b/contrib/mm/mmroff.pl
index 3cdf8fd87..bcd86ab83 100644
--- a/contrib/mm/mmroff.pl
+++ b/contrib/mm/mmroff.pl
@@ -1,5 +1,5 @@
#!@PERL@
-# Copyright (C) 1989-2020 Free Software Foundation, Inc.
+# Copyright (C) 1989-2023 Free Software Foundation, Inc.
#
# This file is part of groff.
#
@@ -19,6 +19,8 @@
use strict;
use warnings;
+use Config;
+
(my $progname = $0) =~s @.*/@@;
# runs groff in safe mode, that seems to be the default
@@ -47,10 +49,26 @@ if (grep(/^-x$/, @ARGV)) {
@ARGV = grep(!/^-x$/, @ARGV);
}
+# Locate groff executable.
+my $path = $ENV{'GROFF_BIN_PATH'};
+my $groff;
+
+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";
-my $second_pass = "groff -mm @ARGV";
+my $first_pass = "$groff -rRef=1 -z -mm @ARGV";
+my $second_pass = "$groff -mm @ARGV";
my (%cur, $rfilename, $max_height, $imacro, $max_width, @out, @indi);
open(MACRO, "$first_pass 2>&1 |") || die "run $first_pass:$!";
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 33/126: [mm]: Make "mmroff" honor `GROFF_BIN_PATH`.,
G. Branden Robinson <=