Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / mantools / mansect
blob60262be593505a805d935a744d71e0b66262adbe
1 #!/bin/sh
3 # mansect - extract manual chapter number from source comment
5 # @(#) mansect.sh 1.2 11/4/89 15:56:37
7 LANG=
9 : process arguments
11 while :
13 case $1 in
14 [0-9]) SECT=$1;;
15 -) LANG=$1; B='[#:]';;
16 -a) LANG=$1; B='#';;
17 -c) LANG=$1; B='\/\*';;
18 -f) LANG=$1; B='[Cc]';;
19 -m) LANG=$1; B='#';;
20 -n|-t) LANG=$1; B='\\"';;
21 -p) LANG=$1; B='{';;
22 -r) LANG=$1; B='#';;
23 -C) LANG=$1; B=$2; shift;;
24 -*) ERROR="unknown option: $1"; break;;
25 "") ERROR="missing file argument"; break;;
26 *) break;;
27 esac
28 shift
29 done
31 # check error status
33 case $ERROR in
34 "") ;;
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;;
37 esac
39 # set up for file suffix processing
41 case $LANG in
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;
46 esac
48 # extract chapter number from file
50 for i
52 case $LANG in
53 "") eval B\="\$`expr $i : '.*\.\([^.]*\)$'`"
54 test "$B" || { echo "$0: unknown suffix: '$i'; assuming c" 1>&2; B=$c; }
55 esac
56 sed -n '
57 /^'"$B"'++/,/^'"$B"'--/{
58 s/[ ]*$//
59 /^'"$B"' NAME/{
61 s/^.*\n'"$B"'.*[ ]\([0-9]\)[ ]*$/\1/p
65 ' $i
66 done
68 exit
70 #++
71 # NAME
72 # mansect 1
73 # SUMMARY
74 # extract manual chapter number from comment
75 # PACKAGE
76 # sdetools
77 # SYNOPSIS
78 # mansect [-|-a|-c|-f|-m|-m|-n|-p|-t|-r|-C] file(s)
79 # DESCRIPTION
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.
91 # .nf
92 # .ft C
93 option suffix language comment
95 - .sh shell [:#]
96 -a .awk awk #
97 -c .c .h .l .y c lex yacc /*
98 -f .f .fh fortran [Cc]
99 -m .mk make #
100 -n .man .mn .ms .nr nroff troff \\"
101 -p .p .ph pascal {
102 -r .r .rh ratfor #
103 -C any language next argument
104 # .ft
105 # COMMANDS
106 # sh(1), sed(1)
107 # SEE ALSO
108 # newsrc(1), xman(1)
109 # The earlier commands new(1), mod(1), mkman(1) and dssman(1)
110 # by Ruud Zwart and Ben Noordzij (Erasmus University, Rotterdam)
111 # DIAGNOSTICS
112 # The program complaints if an unknown language is specified
113 # of if the language cannot be deduced from the file suffix.
114 # AUTHOR(S)
115 # W.Z. Venema
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
119 # CREATION DATE
120 # Sun Feb 15 21:40:28 GMT+1:00 1987
121 # LAST MODIFICATION
122 # 11/4/89 15:56:37
123 # VERSION/RELEASE
124 # 1.2