Don't use .Xo/.Xc. Fix date format.
[netbsd-mini2440.git] / gnu / usr.bin / groff / etc / grog.sh
blobbe8da30ff17211ada96d1533bf5c77967953f2da
1 #!/bin/sh
2 # grog -- guess options for groff command
3 # Like doctype in Kernighan & Pike, Unix Programming Environment, pp 306-8.
5 soelim=gsoelim
7 opts=
9 for arg
11 case "$arg" in
12 --)
13 shift; break;;
15 break;;
16 -*)
17 opts="$opts $arg"; shift;;
19 break;;
20 esac
21 done
23 egrep -h '^\.(P|[LI]P|[pnil]p|TS|EQ|TH|SH|so)' $* \
24 | sed -e '/^\.so/s/^.*$/.SO_START\
26 .SO_END/' \
27 | $soelim \
28 | egrep '^\.(P|[LI]P|[pnil]p|TS|EQ|TH|SH|SO_START|SO_END)' \
29 | awk '
30 /^\.SO_START$/ { so = 1 }
31 /^\.SO_END$/ { so = 0 }
32 /^\.TS/ { tbl++; if (so > 0) soelim++ }
33 /^\.PS/ { pic++; if (so > 0) soelim++ }
34 /^\.EQ/ { eqn++; if (so > 0) soelim++ }
35 /^\.TH/ { TH++ }
36 /^\.[PLI]P/ { PP++ }
37 /^\.P$/ { P++ }
38 /^\.SH/ { SH++ }
39 /^\.[pnil]p/ { me++ }
41 END {
42 if (files ~ /^-/)
43 files = "-- " files
44 printf "groff"
45 if (pic > 0 || tbl > 0 || eqn > 0) {
46 printf " -"
47 if (soelim > 0) printf "s"
48 if (pic > 0) printf "p"
49 if (tbl > 0) printf "t"
50 if (eqn > 0) printf "e"
52 if (me > 0)
53 printf " -me"
54 else if (SH > 0 && TH > 0)
55 printf " -man"
56 else if (PP > 0)
57 printf " -ms"
58 else if (P > 0)
59 printf " -mm"
60 if (opts != "")
61 printf "%s", opts
62 if (files != "")
63 printf " %s", files
64 print
65 }' "opts=$opts" "files=$*" -