]> git.ipfire.org Git - thirdparty/man-pages.git/blob - scripts/find_slashes_no_parens.sh
Maintenance scripts
[thirdparty/man-pages.git] / scripts / find_slashes_no_parens.sh
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
21
22 if test $# -lt 2; then
23 echo "Usage: $0 man-page-root-dir file file..." 1>&2
24 exit 1
25 fi
26
27 dir=$1
28
29 if ! test -d $dir/man2 || ! test -d $dir/man3; then
30 echo "Can't find man2 and man3 under $dir" 1>&2
31 exit 1
32 fi
33
34 shift 1
35
36 echo "This will probably take a few minutes..." 1>&2
37
38 regexp_file=tmp.$0.regexp
39 rm -f $regexp_file
40
41 # We grep out a few page names that are likely to generate false
42 # positives...
43
44 for page in $(
45
46 find $dir/man2/* $dir/man3/* -type f -name '*.[23]' |
47 egrep -v '/(stderr|stdin|stdout|errno|termios|string)\..$'); do
48
49 base=$(basename $page | sed -e 's/\.[23]$//')
50
51 echo "\\\\f[BI]$base\\\\f[PB][^(]" >> $regexp_file
52 echo "\\\\f[BI]$base\\\\f[PB]\$" >> $regexp_file
53 done
54
55 sort -o $regexp_file $regexp_file # Not really needed
56
57 echo "Built regexp file; now about to grep..." 1>&2
58
59 grep -f $regexp_file $*
60
61 rm -f $regexp_file