makedoc.sed 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # By Giuseppe Borzi' - my first sed scriptfile
  2. # cancels lines after the proglogue
  3. # Modified by Pablo Santamaria for section 3 of manual pages
  4. 1,/END\ PROLOGUE/!d
  5. 1,/END\ PROLOGUE/{
  6. # defines and print the title
  7. /^\*DECK/{
  8. s/^\*DECK *\(.*\)/.TH \1 3/
  9. p
  10. s/.*/.SH SYNOPSIS/
  11. }
  12. s/^ *//
  13. # The hell !
  14. /^C\*\*\*BEGIN PROLOGUE/{
  15. # convert to lowercase for use in NAME
  16. y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
  17. # append next line
  18. N
  19. s/^c\*\*\*begin prologue *\([a-z0-9]*\)\nC\*\*\*PURPOSE *\(.*\)/\1 \\- \2/
  20. t nosubsidiary
  21. s/\nC\*\*\*SUBSIDIARY//
  22. N
  23. s/^c\*\*\*begin prologue *\([a-z0-9]*\)\nC\*\*\*PURPOSE *\(.*\)/\1 \\- \2/
  24. :nosubsidiary
  25. h
  26. # print NAME heading
  27. s/.*/.SH NAME/
  28. p
  29. # retrieve original line from hold space and rewrite
  30. x
  31. }
  32. # cancels END PROLOGUE
  33. s/^C\*\*\*END PROLOGUE.*//
  34. # change each C*** to a roff section heading
  35. s/^C\*\*\*/.SH /
  36. # builds headings formed by two or more words
  37. /\.SH ROUTINES CALLED/{
  38. h
  39. s/\(\.SH ROUTINES CALLED\).*/\1/
  40. p
  41. x
  42. s/\.SH ROUTINES CALLED *\(.*\)/\1/
  43. }
  44. /\.SH REVISION HISTORY (YYMMDD)/{
  45. h
  46. s/\(\.SH REVISION HISTORY (YYMMDD)\).*/\1/
  47. p
  48. s/\(\.SH REVISION HISTORY (YYMMDD)\).*/.PD 0/
  49. p
  50. x
  51. s/\.SH REVISION HISTORY (YYMMDD) *\(.*\)/\1/
  52. }
  53. /\.SH COMMON BLOCKS/{
  54. h
  55. s/\(\.SH COMMON BLOCKS\).*/\1/
  56. p
  57. x
  58. s/\.SH COMMON BLOCKS *\(.*\)/\1/
  59. }
  60. /\.SH SEE ALSO/{
  61. h
  62. s/\(\.SH SEE ALSO\).*/\1/
  63. p
  64. x
  65. s/\.SH SEE ALSO *\(.*\)/\1/
  66. }
  67. # builds headings formed by one word
  68. /\.SH/{
  69. h
  70. s/\(\.SH *[A-Z]*\).*/\1/
  71. p
  72. x
  73. s/\.SH *[A-Z]* *\(.*\)/\1/
  74. }
  75. # strip initial C and eventually spaces
  76. s/^C *//
  77. s/^C$//
  78. # this is Y2K compliant !
  79. /[0789][0-9][01][0-9][0-3][0-9]/i\
  80. .P
  81. }