[net.sources] "extract" source

req@snow.UUCP (Russell Quin) (05/22/85)

I find the enclosed little program useful for writing and debugging nroff/troff
macros.  There is a manual page, but briefly, it allows you to say
	extract -ms PP LP
to print the -ms definition of the PP and LP macros.  You can also say
	extract -fpathname ff
to print the definition of .ff in the file "pathname".
This is a sh archive.  To unload it, cut at the line and put into a file called
extract.dist (if you like), and then say
	sh extract.dist
You will probably have to remove my .signature and any other footers that the
mailers put there from the end of the article.
Enjoy!
		- Russell
#
#-------------------- CUT HERE --------------------------------------------
#!/bin/sh
echo 'Start of extract.dist (part 1 of 1):'
echo 'x - extract'
sed 's/^X//' > extract << '/'
X#! /bin/sh
Xmac_file=/usr/lib/tmac/tmac.s    # default macro package is -ms
Xfor i in "$@"
Xdo
X	case $i in
X
X	-m*)
X		mac_file=/usr/lib/tmac/tmac.`echo $i |sed -e 's/-m//'`
X		;;
X	-f*)
X		mac_file=`echo $i | sed -e 's/-f//'`
X		;;
X	*)
X		soelim ${mac_file} | sed -e "
X/^\.[ 	]*de[ 	]*$i/,/^\.\./p
Xd"
X		;;
X	esac
Xdone
/
echo 'x - extract.1'
sed 's/^X//' > extract.1 << '/'
X.TH EXTRACT 1R
X.SH NAME
Xextract \- extract troff definitions from macro packages
X.SH SYNOPSIS
X.B extract 
X[
X.I options
X]
X.B macro_name
X.SH DESCRIPTION
X.I extract
Xis intended to be useful for writers and testers of troff macros.
XIt attempts to find the definition[s] of the macros given as arguments in
Xthe appropriate places -- /usr/lib/tmac/tmac.s is the default file,
Xcontaining the ms macros.
X.PP
XOptions are -f\c
X.I file
Xwhich looks in the named file, and -m\fIpackage\fP, which behaves as the
Xtroff -m flag.
X.SH EXAMPLE
X.PP
Xextract -man pp
X.br
X\&\!	.de SH
X.br
X\&\!	.}X 0
X.br
X\&\!	.nr )E 2
X.br
X\&\!	\e&\e\e$1 \e|\e\e$2 \e|\e\e$3 \e|\e\e$4 \e|\e\e$5 \e|\e\e$6
X.br
X\&\!	..
X.br
X.sp
X.SH "SEE ALSO"
Xtroff(1), soelim(1), man(7), ms(7)
/
echo 'extract.dist complete.'
exit
#
#---------- CUT HERE TOO!!! ------
-- 
		... mcvax!ukc!qtlon!flame!ubu!req
Striving to promote the interproduction of epimorphistic conformability ....