]> git.ipfire.org Git - thirdparty/man-pages.git/blame - scripts/find_dots_no_parens.sh
scripts/sortman: Use version sort
[thirdparty/man-pages.git] / scripts / find_dots_no_parens.sh
CommitLineData
6f9c0c6b
MK
1#!/bin/sh
2#
3# find_dot_no_parens.sh
4#
5# Look for function names after /^.[BIR]/ 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_dots_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 take probably a few moments..." 1>&2
52
53awk_script_file=tmp.$0.awk
54rm -f $awk_script_file
55
56# We grep out a few page names that are likely to generate false
57# positives...
3511dcdb 58
6f9c0c6b
MK
59echo '{' >> $awk_script_file
60echo ' myvar = $2;' >> $awk_script_file
61echo ' gsub("[^a-z_0-9]*$", "", myvar);' >> $awk_script_file
62echo ' if ( myvar == "NOMATCHESFORTHIS" || ' >> $awk_script_file
63
64for page in $(
65
66 find $dir/man2/* $dir/man3/* -type f -name '*.[23]' |
67 egrep -v '/(stderr|stdin|stdout|errno|termios|string)\..$'); do
68
69 base=$(basename $page | sed -e 's/\.[23]$//')
70 echo " myvar == \"$base\" ||" >> $awk_script_file
71
72done
73
74echo ' myvar == "NOMATCHESFORTHIS" )' >> $awk_script_file
75echo ' print $0' >> $awk_script_file
76echo '}' >> $awk_script_file
77
78grep '^\.[BRI][BRI]* [a-zA-Z0-9_][a-zA-Z0-9_]*[^a-zA-Z_]*$' $* |
79 awk -f $awk_script_file | grep -v '([0-9]*)'
80
6f9c0c6b 81rm -f $awk_script_file
3399ba3a 82exit 0