home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / c / c2man-2.0pl33.lha / c2man-2.0 / fixexamp.in < prev    next >
Encoding:
Text File  |  1995-01-24  |  1.7 KB  |  61 lines

  1. # $Id: fixexamp.in,v 2.0.1.3 1994/05/12 01:29:35 greyham Exp $
  2. # Fix up c2man output for inclusion of examples in the c2man manual page.
  3. # This file gets processed to remove comments because some sed's can't handle
  4. # them. Can you believe it?.
  5.  
  6. # The double backslashes in variable interpolations are because sed consumes
  7. # one, not because we're defining macros here (we aren't).
  8.  
  9. # special hack: rename ctype_ex to ctype just to make that example neat.
  10. s/ctype_ex/ctype/
  11.  
  12. # replace the .TH line with a title line.
  13. # we only alter the title length just as the title line is output so an example
  14. # that goes over a page break doesn't damage the real manual page's header.
  15. # Also, calculate and remember the shortened line length: groff doesn't reset
  16. # .ll in .SH & .TP macros, so we use an absolute value later rather than
  17. # relative changes.
  18. /^\.TH /{
  19. s/^\.TH "\([^"]*\)" \([^ ]*\) .*/.ds [H \1\\|(\\|\2\\|)/
  20. a\
  21. .ds [D UNIX Programmer's Manual\
  22. .po +1i\
  23. .lt -1.5i\
  24. .tl @\\*([H@\\*([D@\\*([H@\
  25. .lt +1.5i\
  26. .po -1i\
  27. .RS +1i\
  28. .nr CL \\n(.l-0.5i
  29. }
  30.  
  31. # surround all the .SH and .SS lines with page offset indents
  32. # the .ne line will force a page break before the .po is evaluated, in the case
  33. # where a .SH in an example is at the very bottom of the page. Otherwise the .SH
  34. # could cause the break, resulting in the wrong .po setting for the new page's
  35. # title line.
  36. /^\.S[SH] /{
  37. i\
  38. .br\
  39. .ne 3\
  40. .RE\
  41. .po +1i
  42. a\
  43. .po -1i\
  44. .RS +1i\
  45. .ll \\n(CLu
  46. }
  47.  
  48. # handle tagged paragraphs; .TP retains .RS setting, but resets .ll
  49. # since the parameter to .TP is on the next line, we read the next line in first
  50. /^.TP/{
  51. n
  52. a\
  53. .ll \\n(CLu
  54. }
  55.  
  56. # up the line length again at the end of the example file
  57. $a\
  58. .ll \\n(CLu+0.5i\
  59. .RE
  60.  
  61.