From: Brantley Coile <brantley@coraid.com>
To: Jaap Akkerhuis <jaapna@xs4all.nl>
Cc: "tuhs@minnie.tuhs.org" <tuhs@minnie.tuhs.org>
Subject: Re: [TUHS] Proliferation of options is great simplification of pipes, really?
Date: Tue, 23 Feb 2021 13:23:59 +0000 [thread overview]
Message-ID: <47E2CC0C-83C7-4C49-B80D-5510F50B7655@coraid.com> (raw)
In-Reply-To: <F8BFB248-CCB3-4B65-897E-0954327AD388@xs4all.nl>
#!/bin/rc
# doctype: synthesize proper command line for troff
troff=troff
eqn=eqn
prefer=prefer
opt=''
dev=''
while(~ $1 -*){
switch($1){
case -n;
troff=nroff
eqn=neqn
prefer='prefer -n'
case -T
dev=$1
case -*
opt=$opt' $1'
}
shift
}
ifs='
'{
files=`{echo $*}
}
grep -h '\$LIST|\|reference|Jp|^\.(EQ|TS|\[|PS|IS|GS|G1|GD|PP|BM|LP|BP|PI|cstart|begin|TH...|TI)|^\.P$' $* |
sort -u |
awk '
BEGIN { files = "'$"files'" }
/\$LIST/ { e++ }
/^\.PP/ { ms++ }
/^\.LP/ { ms++ }
/^\.EQ/ { eqn++ }
/^\.TS/ { tbl++ }
/^\.PS/ { pic++ }
/^\.IS/ { ideal++ }
/^\.GS/ { tped++ }
/^\.G1/ { grap++; pic++ }
/^\.GD/ { dag++; pic++ }
/^\.\[/ { refer++ }
/\|reference/ { prefer++ }
/^\.cstart/ { chem++; pic++ }
/^\.begin +dformat/ { dformat++; pic++ }
/^\.TH.../ { man++ }
/^\.BM/ { lbits++ }
/^\.P$/ { mm++ }
/^\.BP/ { pictures++ }
/^\.PI/ { pictures++ }
/^\.TI/ { mcs++ }
/^\.ft *Jp|\\f\(Jp/ { nihongo++ }
END {
x = ""
if (refer) {
if (e) x = "refer/refer -e " files " | "
else x = "refer/refer " files "| "
files = ""
}
else if (prefer) { x = "cat " files "| '$prefer'| "; files = "" }
if (tped) { x = x "tped " files " | "; files = "" }
if (dag) { x = x "dag " files " | "; files = "" }
if (ideal) { x = x "ideal -q " files " | "; files = "" }
if (grap) { x = x "grap " files " | "; files = "" }
if (chem) { x = x "chem " files " | "; files = "" }
if (dformat) { x = x "dformat " files " | "; files = "" }
if (pic) { x = x "pic " files " | "; files = "" }
if (tbl) { x = x "tbl " files " | "; files = "" }
if (eqn) { x = x "'$eqn' '$dev' " files " | "; files = "" }
x = x "'$troff' "
if (man) x = x "-man"
else if (ms) x = x "-ms"
else if (mm) x = x "-mm"
if (mcs) x = x " -mcs"
if (lbits) x = x " -mbits"
if (pictures) x = x " -mpictures"
if (nihongo) x = x " -mnihongo"
x = x " '$opt' '$dev' " files
print x
}'
> On Feb 23, 2021, at 5:42 AM, Jaap Akkerhuis <jaapna@xs4all.nl> wrote:
>
>
>
>> On Feb 23, 2021, at 3:47, M Douglas McIlroy <m.douglas.mcilroy@dartmouth.edu> wrote:
>>
>>> I can imagine a simple perl (or python or whatever) script that would run
>>> through groff input [and] determine which preprocessors are actually
>>> needed ...
>>
>> Brian imagined such and implemented it way back when. Though I used
>> it, I've forgotten its name. One probably could have fooled it by
>> tricks like calling pic only in a .so file and perhaps renaming .so.
>> But I never heard of it failing in real life. It does impose an extra
>> pass over the input, but may well save a pass compared to the
>> defensive groff -pet that I often use or to the rerun necessary when I
>> forget to mention some or all of the filters.
>
>
> If I remember correctly, it was an awk script printing out the
> suggested pipeline to use. One could then cut and paste that line.
>
> jaap
next prev parent reply other threads:[~2021-02-23 13:39 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-23 2:47 M Douglas McIlroy
2021-02-23 10:42 ` Jaap Akkerhuis
2021-02-23 13:23 ` Brantley Coile [this message]
2021-02-23 13:49 ` Ralph Corderoy
-- strict thread matches above, loose matches on Subject: below --
2021-02-24 19:38 Norman Wilson
2021-02-23 15:04 Steve Simon
2021-02-24 2:42 ` M Douglas McIlroy
2021-02-22 2:34 Will Senn
2021-02-22 3:32 ` G. Branden Robinson
2021-02-22 4:32 ` Dan Stromberg
2021-02-22 4:34 ` Will Senn
2021-02-22 5:45 ` G. Branden Robinson
2021-02-22 15:49 ` John P. Linderman
2021-02-22 15:57 ` William Cheswick
2021-02-22 16:03 ` John P. Linderman
2021-02-22 21:16 ` G. Branden Robinson
2021-02-22 16:02 ` Warner Losh
2021-02-22 16:12 ` Robert Clausecker
2021-02-22 17:15 ` John Cowan
2021-02-23 0:24 ` Steffen Nurpmeso
2021-02-22 21:14 ` G. Branden Robinson
2021-02-22 7:20 ` Rich Morin
2021-02-22 18:27 ` Jon Steinhart
2021-02-22 19:30 ` Richard Salz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47E2CC0C-83C7-4C49-B80D-5510F50B7655@coraid.com \
--to=brantley@coraid.com \
--cc=jaapna@xs4all.nl \
--cc=tuhs@minnie.tuhs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).