rembo@unisoft.UUCP (Tony Rems) (10/13/90)
Is there a way to tell what macro package a troff/nroff file is using? Please e-mail as well as post. Thanks in advance. -Tony
gwyn@smoke.BRL.MIL (Doug Gwyn) (10/14/90)
In article <3164@unisoft.UUCP> rembo@unisoft.UUCP (Tony Rems) writes: >Is there a way to tell what macro package a troff/nroff file is using? Of course not. Users can provide their own macro packages. However, assuming one of the standard ones is involved, you might be able to tell by seeing what macros it appears to be using. The following "doctype" script demonstrates this, as well as finding other useful information of the same general nature. #!/usr/5bin/sh # doctype -- synthesize proper command line for troff # adapted from Kernighan & Pike # last edit: 90/07/30 D A Gwyn # SCCS ID: @(#)doctype.sh 1.12 PATH=/usr/5bin:/bin:/usr/bin if pdp11 then MACDIR=/usr/lib/tmac else MACDIR=/usr/5lib/tmac # BRL System V emulation fi eopt= macs= opts= topt= for i do case "$i" in -e) eopt="$i"; shift;; -m*) macs="$macs $i"; shift;; -T*) topt=" $i"; shift;; --) shift; break;; -) break;; -*) opts="$opts $i"; shift;; *) break;; esac done if [ $# -gt 0 ] then s="cat $* | " else s= fi t=`cat $* | egrep '^\.(EQ|TS|\[|P|LP|G1|IS|SH|begin)' | sort -u | awk ' /^\.SH *(NAME|SYNOPSIS|DESCRIPTION)/ { man++ } /^\.P$/ { mm++ } /^\.[LP]P/ { ms++ } /^\.EQ/ { eqn++ } /^\.TS/ { tbl++ } /^\.P[FS]/ { pic++ } /^\.G1/ { grap++ } /^\.IS/ { ideal++ } /^\.\[/ { refer++ } /^\.begin[ ]*stills/ { stills++ } END { if (refer > 0) printf "refer | " if (grap > 0) printf "grap | " if (grap > 0 || pic > 0) printf "_PIC_ | " if (ideal > 0) printf "ideal | " if (stills > 0) printf "stills | " if (tbl > 0) printf "tbl | " if (eqn > 0) printf "_EQN_ | " printf "_TROFF_" if (grap > 0 || pic > 0) printf " -mpic" if (man > 0) printf " -man" if (mm > 0 && man == 0) printf " -mm" if (ms > 0 && mm == 0 && man == 0) printf " -ms" printf " -\n" } ' | sed -e s/_PIC_/"pic$topt"/ -e s/_EQN_/"eqn$topt"/ \ -e s/_TROFF_/"troff$topt$opts$macs"/ -e s%' -m'%" $MACDIR/tmac."%g` if [ -n "$eopt" ] then eval "$s$t" else echo $s$t fi
chet@cwns1.INS.CWRU.Edu (Chet Ramey) (10/19/90)
In article <14147@smoke.BRL.MIL> gwyn@smoke.BRL.MIL (Doug Gwyn) writes: >However, assuming one of the standard ones is involved, you might >be able to tell by seeing what macros it appears to be using. The >following "doctype" script demonstrates this, as well as finding >other useful information of the same general nature. This is a nice script. Here's a version that works with groff and recognizes -me. I took out some of the stuff in Doug's version that we don't have and groff doesn't provide. Chet #!/bin/bash # gdoctype -- synthesize proper command line for groff # adapted from Kernighan & Pike # # Chet Ramey chet@ins.CWRU.Edu # Originally from: D A Gwyn # # changed to work with groff 10/16/90 # support for recognizing -me and gremlin 10/17/90 # # Caveats: # o we test for gremlin, but since I don't have it, this doesn't # do anything # o this always runs groff -v # PATH=/usr/ucb:/bin:/usr/bin:/usr/local/bin/gnu:/usr/local/bin MACDIR=/usr/lib/tmac eopt= macs= opts= topt= for i do case "$i" in -e) eopt="$i"; shift;; -m*) macs="$macs $i"; shift;; -T*) topt="$i"; shift;; --) shift; break;; -) break;; -*) opts="$opts $i"; shift;; *) break;; esac done if [ $# -gt 0 ] then s="cat $* | " else s= fi t=`cat $* | egrep '^\.(EQ|TS|\[|P|LP|G1|IS|SH|pp|GS)' | sort -u | awk ' /^\.SH *(NAME|SYNOPSIS|DESCRIPTION)/ { man++ } /^\.P$/ { mm++ } /^\.[LP]P/ { ms++ } /^\.pp/ { me++ } /^\.EQ/ { eqn++ } /^\.TS/ { tbl++ } /^\.P[FS]/ { pic++ } /^\.G1/ { grap++ } /^\.IS/ { ideal++ } /^\.\[/ { refer++ } /^\.GS/ { gremlin++ } END { if (refer > 0) printf "refer | " if (grap > 0) printf "grap | " if (ideal > 0) printf "ideal | " printf "groff -v " if (pic > 0) printf "-p " if (tbl > 0) printf "-t " if (eqn > 0) printf "-e " if (man > 0) printf " -man" if (mm > 0 && man == 0) printf " -mm" if (ms > 0 && mm == 0 && man == 0) printf " -ms" if (me > 0 && ms == 0 && mm == 0 && man == 0) printf " -me" printf "\n" } '` # # Add any -Tdev options # if [ -n "$topt" ] ; then t="$t $topt" fi # # Add any miscellaneous options for groff # if [ -n "$opts" ] ; then t="$t $opts" fi # # Add any additional macro packages # if [ -n "$macs" ] ; then t="$t $macs" fi # # Add use of standard input # t="$t -" if [ -n "$eopt" ] ; then eval "$s$t" else echo $s$t fi exit 0 -- Chet Ramey ``As I recall, Doug was keen on boxing. But Network Services Group when he learned to walk, he took up puttin' Case Western Reserve University the boot in the groin.'' chet@ins.CWRU.Edu