3 # mansect - extract manual chapter number from source comment
5 # @(#) mansect.sh 1.2 11/4/89 15:56:37
15 -) LANG
=$1; B
='[#:]';;
17 -c) LANG
=$1; B
='\/\*';;
18 -f) LANG
=$1; B
='[Cc]';;
20 -n|
-t) LANG
=$1; B
='\\"';;
23 -C) LANG
=$1; B
=$2; shift;;
24 -*) ERROR
="unknown option: $1"; break;;
25 "") ERROR
="missing file argument"; break;;
35 *) echo "$0: $ERROR" 1>&2
36 echo "usage: $0 [-|-a|-c|-f|-m|-n|-p|-t|-r|-C] file(s)" 1>&2; exit 1;;
39 # set up for file suffix processing
42 "") sh
='[:#]'; r
='#'; rh
=$r; awk='#'; mk
='#';
43 c
='\/\*'; d
=$c; h
=$c; y
=$c; l
=$c;
44 f
='[Cc]'; fh
=$f; p
='{'; ph
=$p;
45 ms
='\\"'; nr
=$ms; mn
=$ms; man
=$ms;
48 # extract chapter number from file
53 "") eval B\
="\$`expr $i : '.*\.\([^.]*\)$'`"
54 test "$B" ||
{ echo "$0: unknown suffix: '$i'; assuming c" 1>&2; B
=$c; }
57 /^'"$B"'++/,/^'"$B"'--/{
61 s/^.*\n'"$B"'.*[ ]\([0-9]\)[ ]*$/\1/p
74 # extract manual chapter number from comment
78 # mansect [-|-a|-c|-f|-m|-m|-n|-p|-t|-r|-C] file(s)
80 # \fImansect\fR extracts the manual chapter number from
81 # source file comments in the style of \fInewsrc(1)\fR.
82 # Typically, \fImansect\fR is integrated with \fImake(1)\fR scripts.
84 # Source files are processed in the indicated order; if no
85 # files are specified the command produces no output.
87 # The source file language can be specified through a command-line
88 # option, or can be implied by the filename suffix.
89 # The expected start-of-comment symbol is shown in the last column.
93 option suffix language comment
97 -c .c .h .l .y c
lex yacc /*
98 -f .f .fh fortran
[Cc
]
100 -n .man .mn .ms .nr nroff troff
\\"
103 -C any language next argument
109 # The earlier commands new(1), mod(1), mkman(1) and dssman(1)
110 # by Ruud Zwart and Ben Noordzij (Erasmus University, Rotterdam)
112 # The program complaints if an unknown language is specified
113 # of if the language cannot be deduced from the file suffix.
116 # Eindhoven University of Technology
117 # Department of Mathematics and Computer Science
118 # Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
120 # Sun Feb 15 21:40:28 GMT+1:00 1987