mansect revision 1.1 1 1.1 tron #!/bin/sh
2 1.1 tron
3 1.1 tron # mansect - extract manual chapter number from source comment
4 1.1 tron
5 1.1 tron # @(#) mansect.sh 1.2 11/4/89 15:56:37
6 1.1 tron
7 1.1 tron LANG=
8 1.1 tron
9 1.1 tron : process arguments
10 1.1 tron
11 1.1 tron while :
12 1.1 tron do
13 1.1 tron case $1 in
14 1.1 tron [0-9]) SECT=$1;;
15 1.1 tron -) LANG=$1; B='[#:]';;
16 1.1 tron -a) LANG=$1; B='#';;
17 1.1 tron -c) LANG=$1; B='\/\*';;
18 1.1 tron -f) LANG=$1; B='[Cc]';;
19 1.1 tron -m) LANG=$1; B='#';;
20 1.1 tron -n|-t) LANG=$1; B='\\"';;
21 1.1 tron -p) LANG=$1; B='{';;
22 1.1 tron -r) LANG=$1; B='#';;
23 1.1 tron -C) LANG=$1; B=$2; shift;;
24 1.1 tron -*) ERROR="unknown option: $1"; break;;
25 1.1 tron "") ERROR="missing file argument"; break;;
26 1.1 tron *) break;;
27 1.1 tron esac
28 1.1 tron shift
29 1.1 tron done
30 1.1 tron
31 1.1 tron # check error status
32 1.1 tron
33 1.1 tron case $ERROR in
34 1.1 tron "") ;;
35 1.1 tron *) echo "$0: $ERROR" 1>&2
36 1.1 tron echo "usage: $0 [-|-a|-c|-f|-m|-n|-p|-t|-r|-C] file(s)" 1>&2; exit 1;;
37 1.1 tron esac
38 1.1 tron
39 1.1 tron # set up for file suffix processing
40 1.1 tron
41 1.1 tron case $LANG in
42 1.1 tron "") sh='[:#]'; r='#'; rh=$r; awk='#'; mk='#';
43 1.1 tron c='\/\*'; d=$c; h=$c; y=$c; l=$c;
44 1.1 tron f='[Cc]'; fh=$f; p='{'; ph=$p;
45 1.1 tron ms='\\"'; nr=$ms; mn=$ms; man=$ms;
46 1.1 tron esac
47 1.1 tron
48 1.1 tron # extract chapter number from file
49 1.1 tron
50 1.1 tron for i
51 1.1 tron do
52 1.1 tron case $LANG in
53 1.1 tron "") eval B\="\$`expr $i : '.*\.\([^.]*\)$'`"
54 1.1 tron test "$B" || { echo "$0: unknown suffix: '$i'; assuming c" 1>&2; B=$c; }
55 1.1 tron esac
56 1.1 tron sed -n '
57 1.1 tron /^'"$B"'++/,/^'"$B"'--/{
58 1.1 tron s/[ ]*$//
59 1.1 tron /^'"$B"' NAME/{
60 1.1 tron N
61 1.1 tron s/^.*\n'"$B"'.*[ ]\([0-9]\)[ ]*$/\1/p
62 1.1 tron q
63 1.1 tron }
64 1.1 tron }
65 1.1 tron ' $i
66 1.1 tron done
67 1.1 tron
68 1.1 tron exit
69 1.1 tron
70 1.1 tron #++
71 1.1 tron # NAME
72 1.1 tron # mansect 1
73 1.1 tron # SUMMARY
74 1.1 tron # extract manual chapter number from comment
75 1.1 tron # PACKAGE
76 1.1 tron # sdetools
77 1.1 tron # SYNOPSIS
78 1.1 tron # mansect [-|-a|-c|-f|-m|-m|-n|-p|-t|-r|-C] file(s)
79 1.1 tron # DESCRIPTION
80 1.1 tron # \fImansect\fR extracts the manual chapter number from
81 1.1 tron # source file comments in the style of \fInewsrc(1)\fR.
82 1.1 tron # Typically, \fImansect\fR is integrated with \fImake(1)\fR scripts.
83 1.1 tron #
84 1.1 tron # Source files are processed in the indicated order; if no
85 1.1 tron # files are specified the command produces no output.
86 1.1 tron #
87 1.1 tron # The source file language can be specified through a command-line
88 1.1 tron # option, or can be implied by the filename suffix.
89 1.1 tron # The expected start-of-comment symbol is shown in the last column.
90 1.1 tron #
91 1.1 tron # .nf
92 1.1 tron # .ft C
93 1.1 tron option suffix language comment
94 1.1 tron
95 1.1 tron - .sh shell [:#]
96 1.1 tron -a .awk awk #
97 1.1 tron -c .c .h .l .y c lex yacc /*
98 1.1 tron -f .f .fh fortran [Cc]
99 1.1 tron -m .mk make #
100 1.1 tron -n .man .mn .ms .nr nroff troff \\"
101 1.1 tron -p .p .ph pascal {
102 1.1 tron -r .r .rh ratfor #
103 1.1 tron -C any language next argument
104 1.1 tron # .ft
105 1.1 tron # COMMANDS
106 1.1 tron # sh(1), sed(1)
107 1.1 tron # SEE ALSO
108 1.1 tron # newsrc(1), xman(1)
109 1.1 tron # The earlier commands new(1), mod(1), mkman(1) and dssman(1)
110 1.1 tron # by Ruud Zwart and Ben Noordzij (Erasmus University, Rotterdam)
111 1.1 tron # DIAGNOSTICS
112 1.1 tron # The program complaints if an unknown language is specified
113 1.1 tron # of if the language cannot be deduced from the file suffix.
114 1.1 tron # AUTHOR(S)
115 1.1 tron # W.Z. Venema
116 1.1 tron # Eindhoven University of Technology
117 1.1 tron # Department of Mathematics and Computer Science
118 1.1 tron # Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
119 1.1 tron # CREATION DATE
120 1.1 tron # Sun Feb 15 21:40:28 GMT+1:00 1987
121 1.1 tron # LAST MODIFICATION
122 1.1 tron # 11/4/89 15:56:37
123 1.1 tron # VERSION/RELEASE
124 1.1 tron # 1.2
125 1.1 tron #--
126