]>
Commit | Line | Data |
---|---|---|
6f9c0c6b MK |
1 | #!/bin/sh |
2 | # | |
3 | # find_slashes_no_parens.sh | |
4 | # | |
5 | # Look for function names inside \f[BI]...\f[PB] that aren't | |
6 | # followed by "()". | |
7 | # | |
8 | # This script is designed to help with "by hand" tidy-ups after | |
9 | # the automated changes made by add_parens_for_own_funcs.sh. | |
10 | # | |
11 | # The first argument to this script names a manual page directory where | |
12 | # 'man2' and 'man3' subdirectories can be found. The pages names in | |
13 | # these directories are used to generate a series of regular expressions | |
14 | # that can be used to search the manual page files that are named in | |
15 | # the remaining command-line arguments. | |
16 | # | |
17 | # Example usage: | |
18 | # | |
19 | # cd man-pages-x.yy | |
20 | # sh find_slashes_no_parens.sh . man?/*.? > matches.log | |
404b6a03 MK |
21 | # |
22 | ###################################################################### | |
23 | # | |
24 | # (C) Copyright 2005 & 2013, Michael Kerrisk | |
25 | # This program is free software; you can redistribute it and/or | |
26 | # modify it under the terms of the GNU General Public License | |
27 | # as published by the Free Software Foundation; either version 2 | |
28 | # of the License, or (at your option) any later version. | |
29 | # | |
30 | # This program is distributed in the hope that it will be useful, | |
31 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
32 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
33 | # GNU General Public License for more details | |
34 | # (http://www.gnu.org/licenses/gpl-2.0.html). | |
35 | # | |
6f9c0c6b MK |
36 | |
37 | if test $# -lt 2; then | |
38 | echo "Usage: $0 man-page-root-dir file file..." 1>&2 | |
39 | exit 1 | |
40 | fi | |
41 | ||
42 | dir=$1 | |
43 | ||
44 | if ! test -d $dir/man2 || ! test -d $dir/man3; then | |
45 | echo "Can't find man2 and man3 under $dir" 1>&2 | |
46 | exit 1 | |
47 | fi | |
48 | ||
49 | shift 1 | |
50 | ||
51 | echo "This will probably take a few minutes..." 1>&2 | |
52 | ||
53 | regexp_file=tmp.$0.regexp | |
54 | rm -f $regexp_file | |
55 | ||
56 | # We grep out a few page names that are likely to generate false | |
57 | # positives... | |
58 | ||
59 | for page in $( | |
60 | ||
61 | find $dir/man2/* $dir/man3/* -type f -name '*.[23]' | | |
62 | egrep -v '/(stderr|stdin|stdout|errno|termios|string)\..$'); do | |
63 | ||
64 | base=$(basename $page | sed -e 's/\.[23]$//') | |
65 | ||
66 | echo "\\\\f[BI]$base\\\\f[PB][^(]" >> $regexp_file | |
67 | echo "\\\\f[BI]$base\\\\f[PB]\$" >> $regexp_file | |
68 | done | |
69 | ||
70 | sort -o $regexp_file $regexp_file # Not really needed | |
71 | ||
72 | echo "Built regexp file; now about to grep..." 1>&2 | |
73 | ||
74 | grep -f $regexp_file $* | |
75 | ||
76 | rm -f $regexp_file | |
3399ba3a | 77 | exit 0 |