doctype 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/bin/rc
  2. # doctype: synthesize proper command line for troff
  3. troff=troff
  4. eqn=eqn
  5. prefer=prefer
  6. opt=''
  7. dev=''
  8. while(~ $1 -*){
  9. switch($1){
  10. case -n;
  11. troff=nroff
  12. eqn=neqn
  13. prefer='prefer -n'
  14. case -T
  15. dev=$1
  16. case -*
  17. opt=$opt' $1'
  18. }
  19. shift
  20. }
  21. ifs='
  22. '{
  23. files=`{echo $*}
  24. }
  25. grep -h '\$LIST|\|reference|^\.(EQ|TS|\[|PS|IS|GS|G1|GD|PP|BM|LP|BP|PI|cstart|begin|TH...)|^\.P$' $* |
  26. sort -u |
  27. awk '
  28. BEGIN { files = "'$files'" }
  29. /\$LIST/ { e++ }
  30. /^\.PP/ { ms++ }
  31. /^\.LP/ { ms++ }
  32. /^\.EQ/ { eqn++ }
  33. /^\.TS/ { tbl++ }
  34. /^\.PS/ { pic++ }
  35. /^\.IS/ { ideal++ }
  36. /^\.GS/ { tped++ }
  37. /^\.G1/ { grap++; pic++ }
  38. /^\.GD/ { dag++; pic++ }
  39. /^\.\[/ { refer++ }
  40. /\|reference/ { prefer++ }
  41. /^\.cstart/ { chem++; pic++ }
  42. /^\.begin +dformat/ { dformat++; pic++ }
  43. /^\.TH.../ { man++ }
  44. /^\.BM/ { lbits++ }
  45. /^\.P$/ { mm++ }
  46. /^\.BP/ { pictures++ }
  47. /^\.PI/ { pictures++ }
  48. END {
  49. x = ""
  50. if (refer) {
  51. if (e) x = "refer -e " files " | "
  52. else x = "refer " files "| "
  53. files = ""
  54. }
  55. else if (prefer) { x = "cat " files "| '$prefer'| "; files = "" }
  56. if (tped) { x = x "tped " files " | "; files = "" }
  57. if (dag) { x = x "dag " files " | "; files = "" }
  58. if (ideal) { x = x "ideal -q " files " | "; files = "" }
  59. if (grap) { x = x "grap " files " | "; files = "" }
  60. if (chem) { x = x "chem " files " | "; files = "" }
  61. if (dformat) { x = x "dformat " files " | "; files = "" }
  62. if (pic) { x = x "pic " files " | "; files = "" }
  63. if (tbl) { x = x "tbl " files " | "; files = "" }
  64. if (eqn) { x = x "'$eqn' '$dev' " files " | "; files = "" }
  65. x = x "'$troff' "
  66. if (man) x = x "-man"
  67. else if (ms) x = x "-ms"
  68. else if (mm) x = x "-mm"
  69. if (lbits) x = x " -mbits"
  70. if (pictures) x = x " -mpictures"
  71. x = x " '$opt' '$dev' " files
  72. print x
  73. }'