]> git.ipfire.org Git - thirdparty/man-pages.git/blame - scripts/find_slashes_no_parens.sh
man_show_fixme.sh: strip extraneous blank line at start of rendered FIXME output
[thirdparty/man-pages.git] / scripts / find_slashes_no_parens.sh
CommitLineData
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
37if test $# -lt 2; then
38 echo "Usage: $0 man-page-root-dir file file..." 1>&2
39 exit 1
40fi
41
42dir=$1
43
44if ! test -d $dir/man2 || ! test -d $dir/man3; then
45 echo "Can't find man2 and man3 under $dir" 1>&2
46 exit 1
47fi
48
49shift 1
50
51echo "This will probably take a few minutes..." 1>&2
52
53regexp_file=tmp.$0.regexp
54rm -f $regexp_file
55
56# We grep out a few page names that are likely to generate false
57# positives...
58
59for 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
68done
69
70sort -o $regexp_file $regexp_file # Not really needed
71
72echo "Built regexp file; now about to grep..." 1>&2
73
74grep -f $regexp_file $*
75
76rm -f $regexp_file
3399ba3a 77exit 0