home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / othergnu / texinf~1.zoo / texinfo.st / texi2roff / texi2index < prev    next >
Encoding:
Text File  |  1993-04-12  |  1.4 KB  |  54 lines

  1. #!/bin/sh
  2.  
  3. # This script takes the file of index entries emitted to stderr by
  4. # troff when processing the output of texi2roff -i and creates up
  5. # to 6 indices (concept, function, keystroke, program, data type,
  6. # variable) as troff input.  If there are no entries for a particular
  7. # type of index, it won't be generated.
  8.  
  9. # Run the output of this script through nroff or troff with one of
  10. # -me, -mm or -ms.  The macros are necessary to provide pagination.
  11.  
  12. # Credit for the creative use of tbl to a posting by jpr@dasys1.
  13. # The tricky part with sed protects index entries beginning with
  14. # characters that make troff drop lines and preserves sort order
  15. # for index entries containing typesetting commands.
  16.  
  17. FILE="$*"
  18.  
  19. sed -n "s/^../&\\\\\\&/p" $FILE \
  20. | sed "
  21.     s/.*/&~+~&/
  22.     :repeat
  23.     s/\\\\f[BIR]\(.*~+~\)/\1/
  24.     s/\\\\f(CW\(.*~+~\)/\1/
  25.     t repeat
  26. " | sort -fd | sed -e 's/.*~+~//' -e 's/[0-9][0-9]*$/    &/'\
  27. | awk '
  28.     BEGIN    {
  29.         titles["c"] = "Concept Index"
  30.         titles["f"] = "Function Index"
  31.         titles["k"] = "Keystroke Index"
  32.         titles["p"] = "Program Index"
  33.         titles["t"] = "Data Type Index"
  34.         titles["v"] = "Variable Index"
  35.         print ".nf"
  36.     }
  37.     {
  38.         if ($1 != prev) {
  39.             if (prev != "")
  40.                 print ".TE"
  41.             print ".bp"
  42.             print ".TS"; print "c s"; print "l r."
  43.             print titles[$1]
  44.             print ""
  45.             prev = $1
  46.         }
  47.         print substr($0, 3, length($0)-2)
  48.     }
  49.     END {
  50.         if (prev != "")
  51.             print ".TE"
  52.     } '  | tbl
  53.  
  54.