diff options
author | wl <wl> | 2007-11-19 20:36:45 +0000 |
---|---|---|
committer | wl <wl> | 2007-11-19 20:36:45 +0000 |
commit | 391f7aaefe811dee10cb1c61b4c1e4e24d6146c9 (patch) | |
tree | f3654f4da190d5112aa1b7f487faf0a8e477ed31 /src | |
parent | 5291a235c550b0b9304a0b8db5069f9045b6dbf4 (diff) | |
download | groff-391f7aaefe811dee10cb1c61b4c1e4e24d6146c9.tar.gz |
* src/roff/nroff/nroff.sh: Handle GROFF_TYPESETTER environment
variable. Problem reported by Michael G Schwern
<schwern@pobox.com>.
* src/roff/nroff/nroff.man: Document it.
Other minor updates.
Diffstat (limited to 'src')
-rw-r--r-- | src/roff/nroff/nroff.man | 68 | ||||
-rw-r--r-- | src/roff/nroff/nroff.sh | 57 |
2 files changed, 83 insertions, 42 deletions
diff --git a/src/roff/nroff/nroff.man b/src/roff/nroff/nroff.man index 0511b45b..19350c72 100644 --- a/src/roff/nroff/nroff.man +++ b/src/roff/nroff/nroff.man @@ -1,5 +1,6 @@ .ig -Copyright (C) 1989-2001, 2002, 2003, 2005 Free Software Foundation, Inc. +Copyright (C) 1989-2001, 2002, 2003, 2005, 2007 + Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -23,17 +24,16 @@ the original English. @g@nroff \- emulate nroff command with groff . .SH SYNOPSIS -.nr a \n(.j -.ad l -.nr i \n(.i -.in +\w'\fB@g@nroff 'u -.ti \niu -.B @g@nroff +. +.\" Redefine OP because no spaces are allowed after an option's argument. .de OP -.ie \\n(.$-1 .RI "[\ \fB\\$1\fP" "\\$2" "\ ]" -.el .RB "[\ " "\\$1" "\ ]" +. ie \\n(.$-1 \ +. RI "[\fB\\$1\fP" "\\$2" "]" +. el \ +. RB "[" "\\$1" "]" .. -. + +.SY @g@nroff .OP \-CchipStUv .OP \-d cs .OP \-M dir @@ -42,9 +42,16 @@ the original English. .OP \-o list .OP \-r cn .OP \-T name -.RI "[\ " "file" "\ .\|.\|.\ ]" -.br -.ad \na +.RI [ file .\|.\|.] +. +.SY @g@nroff +.B \-\-help +. +.SY @g@nroff +.B \-v +| +.B \-\-version +.YS . .SH DESCRIPTION The @@ -52,20 +59,23 @@ The script emulates the .B nroff command using groff. -Only +Only .BR ascii , .BR latin1 , .BR utf8 , and .B cp1047 -are valid arguments for the -.B -T -option, selecting the output encoding emitted by +are devices accepted by +.BR nroff +to select the output encoding emitted by .BR grotty , groff's TTY output device. -If an invalid or no -.BR \-T -option is given, +If neither the +.B GROFF_TYPESETTER +environment variable nor the +.B \-T +command line option (which overrides the environment variable) +specifies a (valid) device, .B @g@nroff checks the current locale to select a default output device. It first tries the @@ -112,7 +122,7 @@ and .BR \-s (which are not implemented in .BR @g@troff ). -Options +Options .B \-p (pic), .B \-t @@ -121,17 +131,29 @@ Options (safer), and .B \-U (unsafe) are passed to -.BR groff . +.BR groff . .B \-v -shows the version number. +and +.B \-\-version +show the version number, +.B \-\-help +prints a help message. . .SH ENVIRONMENT .TP .SM +.B GROFF_TYPESETTER +The default device for +.BR groff . +If not set (which is the normal case), it defaults to `ps'. +. +.TP +.SM .B GROFF_BIN_PATH A colon separated list of directories in which to search for the .B groff executable before searching in PATH. 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 93db893c..afd6bf90 100644 --- a/src/roff/nroff/nroff.sh +++ b/src/roff/nroff/nroff.sh @@ -2,7 +2,7 @@ # Emulate nroff with groff. # # Copyright (C) 1992, 1993, 1994, 1999, 2000, 2001, 2002, 2003, -# 2004, 2005 +# 2004, 2005, 2007 # Free Software Foundation, Inc. # # Written by James Clark, maintained by Werner Lemberg. @@ -26,42 +26,48 @@ # USA. prog="$0" + # Default device. -# First try the "locale charmap" command, because it's most reliable. + +# Check the GROFF_TYPESETTER environment variable. +Tenv=$GROFF_TYPESETTER + +# Try the `locale charmap' command first because it is most reliable. # On systems where it doesn't exist, look at the environment variables. case "`exec 2>/dev/null ; locale charmap`" in UTF-8) - T=-Tutf8 ;; + Tloc=utf8 ;; ISO-8859-1 | ISO-8859-15) - T=-Tlatin1 ;; + Tloc=latin1 ;; IBM-1047) - T=-Tcp1047 ;; + Tloc=cp1047 ;; *) case "${LC_ALL-${LC_CTYPE-${LANG}}}" in *.UTF-8) - T=-Tutf8 ;; + Tloc=utf8 ;; iso_8859_1 | *.ISO-8859-1 | *.ISO8859-1 | \ iso_8859_15 | *.ISO-8859-15 | *.ISO8859-15) - T=-Tlatin1 ;; + Tloc=latin1 ;; *.IBM-1047) - T=-Tcp1047 ;; + Tloc=cp1047 ;; *) case "$LESSCHARSET" in utf-8) - T=-Tutf8 ;; + Tloc=utf8 ;; latin1) - T=-Tlatin1 ;; + Tloc=latin1 ;; cp1047) - T=-Tcp1047 ;; + Tloc=cp1047 ;; *) - T=-Tascii ;; - esac ;; - esac ;; + Tloc=ascii ;; + esac ;; + esac ;; esac -opts= # `for i; do' doesn't work with some versions of sh +Topt= +opts= for i do case $1 in @@ -77,11 +83,8 @@ for i exit 1 ;; -[iptSUC] | -[dMmrno]*) opts="$opts $1" ;; - -Tascii | -Tlatin1 | -Tutf8 | -Tcp1047) - T=$1 ;; -T*) - # ignore other devices - ;; + Topt=$1 ;; -u*) # Solaris 2.2 through at least Solaris 9 `man' invokes # `nroff -u0 ... | col -x'. Ignore the -u0, @@ -109,6 +112,22 @@ for i shift done +if test "x$Topt" != x ; then + T=$Topt +else + if test "x$Tenv" != x ; then + T=-T$Tenv + fi +fi + +case $T in + -Tascii | -Tlatin1 | -Tutf8 | -Tcp1047) + ;; + *) + # ignore other devices and use locale fallback + T=-T$Tloc ;; +esac + # Set up the `GROFF_BIN_PATH' variable # to be exported in the current `GROFF_RUNTIME' environment. |