From ca467670909e8af66bfdad7600fadec77486ddfd Mon Sep 17 00:00:00 2001 From: wlemb Date: Sun, 22 Oct 2000 19:30:15 +0000 Subject: Implement $GROFF_BIN_PATH environment variable (which defaults to $bindir) used for child programs of groff and similar wrappers. * gendefs.sh: Improve documentation. * Makefile.comm (,man.n), src/include/Makefile.sub (defs.h), src/preproc/eqn/Makefile.sub (neqn), src/roff/nroff/Makefile.sub (nroff): Add $(bindir). * src/preproc/eqn/neqn.sh, src/roff/nroff/nroff.sh: Implement $GROFF_BIN_PATH. * src/roff/groff/groff.cc (main): Implement $GROFF_BIN_PATH and $GROFF_PATH__ (the latter for communication with troff). * src/roff/troff/input.cc (main): Use $GROFF_PATH__ for $PATH if set. * src/roff/nroff/nroff.man, src/roff/groff/groff.man, doc/groff.texinfo: Document it. --- ChangeLog | 20 ++++++++++++++++++++ Makefile.comm | 3 ++- Makefile.in | 2 +- doc/groff.texinfo | 18 ++++++++++++++---- gendef.sh | 8 +++++++- src/include/Makefile.sub | 1 + src/preproc/eqn/Makefile.sub | 8 +++++--- src/preproc/eqn/neqn.sh | 4 ++++ src/roff/groff/groff.cc | 22 ++++++++++++++++++++++ src/roff/groff/groff.man | 3 ++- src/roff/nroff/Makefile.sub | 3 ++- src/roff/nroff/nroff.man | 7 +++++++ src/roff/nroff/nroff.sh | 9 ++++++++- src/roff/troff/input.cc | 18 ++++++++++++++++++ 14 files changed, 113 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index bab5051e..2d312a3b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2000-10-22 Werner LEMBERG + + Implement $GROFF_BIN_PATH environment variable (which defaults to + $bindir) used for child programs of groff and similar wrappers. + + * gendefs.sh: Improve documentation. + * Makefile.comm (,man.n), src/include/Makefile.sub (defs.h), + src/preproc/eqn/Makefile.sub (neqn), + src/roff/nroff/Makefile.sub (nroff): Add $(bindir). + * src/preproc/eqn/neqn.sh, src/roff/nroff/nroff.sh: Implement + $GROFF_BIN_PATH. + * src/roff/groff/groff.cc (main): Implement $GROFF_BIN_PATH and + $GROFF_PATH__ (the latter for communication with troff). + * src/roff/troff/input.cc (main): Use $GROFF_PATH__ for $PATH if + set. + * src/roff/nroff/nroff.man, src/roff/groff/groff.man, + doc/groff.texinfo: Document it. + + * doc/groff.texinfo: Improve documentation of troff's -a option. + 2000-10-17 Gaius Mulley * src/roff/troff/node.cc: Fixed calculation of opminx and fixed diff --git a/Makefile.comm b/Makefile.comm index b6cb4eb6..3240f1dd 100644 --- a/Makefile.comm +++ b/Makefile.comm @@ -119,7 +119,8 @@ revision=`sed -e 's/^0$$//' -e 's/^[1-9].*$$/.&/' $(top_srcdir)/REVISION` .man.n: @echo Making $@ from $< @-rm -f $@ - @sed -e "s|@FONTDIR@|$(fontdir)|g" \ + @sed -e "s|@BINDIR@|$(bindir)|g" \ + -e "s|@FONTDIR@|$(fontdir)|g" \ -e "s|@FONTPATH@|$(fontpath)|g" \ -e "s|@MACRODIR@|$(tmacdir)|g" \ -e "s|@MACROPATH@|$(tmacpath)|g" \ diff --git a/Makefile.in b/Makefile.in index 29a3d455..8186bba5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -253,10 +253,10 @@ MDEFINES= \ "top_builddir=$(top_builddir)" \ "prefix=$(prefix)" \ "exec_prefix=$(exec_prefix)" \ - "bindir=$(bindir)" \ "g=$(g)" \ "datadir=$(datadir)" \ "datasubdir=$(datasubdir)" \ + "bindir=$(bindir)" \ "fontdir=$(fontdir)" \ "fontpath=$(fontpath)" \ "tmacdir=$(tmacdir)" \ diff --git a/doc/groff.texinfo b/doc/groff.texinfo index 9b13cfb8..b5fdce27 100644 --- a/doc/groff.texinfo +++ b/doc/groff.texinfo @@ -1189,7 +1189,15 @@ Unsafe mode. Reverts to the old unsafe behaviour. @vindex .A Generate an @acronym{ASCII} approximation of the typeset output. The read-only register @code{.A} is then set to@w{ }1. @xref{Built-in -Registers}. +Registers}. A typical example is + +@example +groff -a -man -Tdvi troff.man | less +@end example + +which shows how lines are broken for the DVI device. Note that this +option is rather useless today since graphic output devices are +available virtually everywhere. @item -b Print a backtrace with each warning or error message. This backtrace @@ -1285,6 +1293,8 @@ If this is set to @var{X}, then @code{groff} will run @code{soelim}. It does not apply to @code{grops}, @code{grodvi}, @code{grotty}, @code{grohtml}, @code{grolj4}, and @code{gxditview}. +@c XXX document default values + @item GROFF_TMAC_PATH @tindex GROFF_TMAC_PATH, environment variable A colon-separated list of directories in which to search for macro @@ -1299,8 +1309,8 @@ The default output device. A colon-separated list of directories in which to search for the @code{dev}@var{name} directory. -@item PATH -@tindex PATH, environment variable +@item GROFF_BIN_PATH +@tindex GROFF_BIN_PATH, environment variable The search path for commands executed by @code{groff}. @item GROFF_TMPDIR @@ -6333,7 +6343,7 @@ name. This would be called as @example -.vl $Id: groff.texinfo,v 1.46 2000/10/14 14:53:59 wlemb Exp $ +.vl $Id: groff.texinfo,v 1.47 2000/10/22 19:30:17 wlemb Exp $ @end example @xref{Request Arguments}. diff --git a/gendef.sh b/gendef.sh index de32279b..4853eef4 100644 --- a/gendef.sh +++ b/gendef.sh @@ -1,4 +1,8 @@ -# gendef filename var=val var=val +# +# gendef filename var=val var=val ... +# +# This script is used to generate src/include/defs.h +# file=$1 shift @@ -26,3 +30,5 @@ test -r $file && cmp -s $t $file || cp $t $file rm -f $t exit 0 + +# eof diff --git a/src/include/Makefile.sub b/src/include/Makefile.sub index 500f0597..cee00d31 100644 --- a/src/include/Makefile.sub +++ b/src/include/Makefile.sub @@ -30,6 +30,7 @@ defs.h: FORCE @$(SHELL) $(top_srcdir)/gendef.sh defs.h \ "PROG_PREFIX=\"$(g)\"" \ "DEVICE=\"$(DEVICE)\"" \ + "BINPATH=\"$(bindir)\"" \ "FONTPATH=\"$(fontpath)\"" \ "MACROPATH=\"$(tmacpath)\"" \ "INDEX_SUFFIX=\"$(indexext)\"" \ diff --git a/src/preproc/eqn/Makefile.sub b/src/preproc/eqn/Makefile.sub index 5d1934a1..bc57df18 100644 --- a/src/preproc/eqn/Makefile.sub +++ b/src/preproc/eqn/Makefile.sub @@ -45,9 +45,11 @@ CLEANADD=neqn all: neqn neqn: neqn.sh - -rm -f neqn - sed -e 's/@g@/$(g)/g' -e $(SH_SCRIPT_SED_CMD) $(srcdir)/neqn.sh >neqn - chmod +x neqn + -rm -f $@ + sed -e 's/@g@/$(g)/g' \ + -e 's|@BINDIR@|$(bindir)|g' \ + -e $(SH_SCRIPT_SED_CMD) $(srcdir)/neqn.sh >$@ + chmod +x $@ install_data: neqn -rm -f $(bindir)/$(NAMEPREFIX)neqn diff --git a/src/preproc/eqn/neqn.sh b/src/preproc/eqn/neqn.sh index 6a60d138..ce4e5a29 100644 --- a/src/preproc/eqn/neqn.sh +++ b/src/preproc/eqn/neqn.sh @@ -2,4 +2,8 @@ # Provision of this shell script should not be taken to imply that use of # GNU eqn with groff -Tascii|-Tlatin1|-Tutf8|-Tcp1047 is supported. +: ${GROFF_BIN_PATH=@BINDIR@} +export PATH=$GROFF_BIN_PATH exec @g@eqn -Tascii ${1+"$@"} + +# eof diff --git a/src/roff/groff/groff.cc b/src/roff/groff/groff.cc index 7a1f16fe..fc96aa02 100644 --- a/src/roff/groff/groff.cc +++ b/src/roff/groff/groff.cc @@ -344,6 +344,28 @@ int main(int argc, char **argv) if (putenv(strsave(e.contents()))) fatal("putenv failed"); } + { + // we save the original path in GROFF_PATH__ and put it into the + // environment -- troff will pick it up later. + char *path = getenv("PATH"); + string e = "GROFF_PATH__"; + e += '='; + if (path && *path) + e += path; + e += '\0'; + if (putenv(strsave(e.contents()))) + fatal("putenv failed"); + char *binpath = getenv("GROFF_BIN_PATH"); + string f = "PATH"; + f += '='; + if (binpath && *binpath) + f += binpath; + else + f += BINPATH; + f += '\0'; + if (putenv(strsave(f.contents()))) + fatal("putenv failed"); + } if (Vflag) { print_commands(); exit(0); diff --git a/src/roff/groff/groff.man b/src/roff/groff/groff.man index 6dc27677..c4f7b36e 100644 --- a/src/roff/groff/groff.man +++ b/src/roff/groff/groff.man @@ -359,9 +359,10 @@ A colon separated list of directories in which to search for the directory. .TP .SM -.B PATH +.B GROFF_BIN_PATH The search path for commands executed by .BR groff . +If not set, `@BINDIR@' is used. .TP .SM .B GROFF_TMPDIR diff --git a/src/roff/nroff/Makefile.sub b/src/roff/nroff/Makefile.sub index 47a1878b..8862383b 100644 --- a/src/roff/nroff/Makefile.sub +++ b/src/roff/nroff/Makefile.sub @@ -6,7 +6,8 @@ all: nroff nroff: nroff.sh rm -f $@ - sed -e $(SH_SCRIPT_SED_CMD) $(srcdir)/nroff.sh >$@ + sed -e 's|@BINDIR@|$(bindir)|g' \ + -e $(SH_SCRIPT_SED_CMD) $(srcdir)/nroff.sh >$@ chmod +x $@ install_data: nroff diff --git a/src/roff/nroff/nroff.man b/src/roff/nroff/nroff.man index a01ea59d..eac88e4b 100644 --- a/src/roff/nroff/nroff.man +++ b/src/roff/nroff/nroff.man @@ -86,6 +86,13 @@ Options .BR groff . .B \-S is passed by default. +.SH ENVIRONMENT +.TP +.SM +.B GROFF_BIN_PATH +A colon separated list of directories in which to search for the +.B groff +executable. If unset, `@BINDIR@' is used. .SH NOTES This shell script is basically intended for use with .BR man (1), diff --git a/src/roff/nroff/nroff.sh b/src/roff/nroff/nroff.sh index b1cab836..d36e0a07 100644 --- a/src/roff/nroff/nroff.sh +++ b/src/roff/nroff/nroff.sh @@ -82,4 +82,11 @@ done # This shell script is intended for use with man, so warnings are # probably not wanted. Also load nroff-style character definitions. -exec groff $safer -Wall -mtty-char $T $opts ${1+"$@"} + +OLD_PATH=$PATH +: ${GROFF_BIN_PATH=@BINDIR@} +export GROFF_BIN_PATH +PATH=$GROFF_BIN_PATH +PATH=$OLD_PATH groff $safer -Wall -mtty-char $T $opts ${1+"$@"} + +# eof diff --git a/src/roff/troff/input.cc b/src/roff/troff/input.cc index 0a18b0d7..9a10d7db 100644 --- a/src/roff/troff/input.cc +++ b/src/roff/troff/input.cc @@ -29,6 +29,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "token.h" #include "div.h" #include "charinfo.h" +#include "stringclass.h" #include "font.h" #include "searchpath.h" #include "macropath.h" @@ -39,6 +40,12 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "nonposix.h" +#ifdef NEED_DECLARATION_PUTENV +extern "C" { + int putenv(const char *); +} +#endif /* NEED_DECLARATION_PUTENV */ + #ifdef ISATTY_MISSING #undef isatty #define isatty(n) (1) @@ -5830,6 +5837,17 @@ int main(int argc, char **argv) int next_page_number; opterr = 0; hresolution = vresolution = 1; + // restore $PATH if called from groff + char* groff_path = getenv("GROFF_PATH__"); + if (groff_path) { + string e = "PATH"; + e += '='; + if (*groff_path) + e += groff_path; + e += '\0'; + if (putenv(strsave(e.contents()))) + fatal("putenv failed"); + } while ((c = getopt(argc, argv, "abivw:W:zCEf:m:n:o:r:d:F:M:T:tqs:RU")) != EOF) switch(c) { -- cgit v1.2.1