changelog shortlog tags branches changeset files revisions annotate raw help

Mercurial > hg > plan9front / rc/bin/doctype

changeset 7243: 34f64dcbbc25
parent: 60238200a287
author: cinap_lenrek@felloff.net
date: Fri, 17 May 2019 18:14:10 +0200
permissions: -rwxr-xr-x
description: 7l: don't hardcode 4k pagesize, use INITRND
1 #!/bin/rc
2 # doctype: synthesize proper command line for troff
3 
4 troff=troff
5 eqn=eqn
6 prefer=prefer
7 opt=''
8 dev=''
9 while(~ $1 -*){
10  switch($1){
11  case -n;
12  troff=nroff
13  eqn=neqn
14  prefer='prefer -n'
15  case -T
16  dev=$1
17  case -*
18  opt=$opt' $1'
19  }
20  shift
21 }
22 ifs='
23 '{
24  files=`{echo $*}
25 }
26 grep -h '\$LIST|\|reference|Jp|^\.(EQ|TS|\[|TPS|PS|IS|GS|G1|GD|PP|BM|LP|BP|PI|cstart|begin|TH...)|^\.P$' $* |
27 sort -u |
28 awk '
29 BEGIN { files = "'$files'" }
30 /\$LIST/ { e++ }
31 /^\.PP/ { ms++ }
32 /^\.LP/ { ms++ }
33 /^\.EQ/ { eqn++ }
34 /^\.TS/ { tbl++ }
35 /^\.PS/ { pic++ }
36 /^\.TPS/ { tpic++; pic++ }
37 /^\.IS/ { ideal++ }
38 /^\.GS/ { tped++ }
39 /^\.G1/ { grap++; pic++ }
40 /^\.GD/ { dag++; pic++ }
41 /^\.\[/ { refer++ }
42 /\|reference/ { prefer++ }
43 /^\.cstart/ { chem++; pic++ }
44 /^\.begin +dformat/ { dformat++; pic++ }
45 /^\.TH.../ { man++ }
46 /^\.BM/ { lbits++ }
47 /^\.P$/ { mm++ }
48 /^\.BP/ { pictures++ }
49 /^\.PI/ { pictures++ }
50 /^\.ft *Jp|\\f\(Jp/ { nihongo++ }
51 END {
52  x = ""
53  if (refer) {
54  if (e) x = "refer/refer -e " files " | "
55  else x = "refer/refer " files "| "
56  files = ""
57  }
58  else if (prefer) { x = "cat " files "| '$prefer'| "; files = "" }
59  if (tpic) { x = x "timepic " files " | "; files = "" }
60  if (tped) { x = x "tped " files " | "; files = "" }
61  if (dag) { x = x "dag " files " | "; files = "" }
62  if (ideal) { x = x "ideal -q " files " | "; files = "" }
63  if (grap) { x = x "grap " files " | "; files = "" }
64  if (chem) { x = x "chem " files " | "; files = "" }
65  if (dformat) { x = x "dformat " files " | "; files = "" }
66  if (pic) { x = x "pic " files " | "; files = "" }
67  if (tbl) { x = x "tbl " files " | "; files = "" }
68  if (eqn) { x = x "'$eqn' '$dev' " files " | "; files = "" }
69  x = x "'$troff' "
70  if (man) x = x "-man"
71  else if (ms) x = x "-ms"
72  else if (mm) x = x "-mm"
73  if (lbits) x = x " -mbits"
74  if (pictures) x = x " -mpictures"
75  if (nihongo) x = x " -mnihongo"
76  x = x " '$opt' '$dev' " files
77  print x
78 }'