Blame scripts/find_slashes_no_parens.sh

Packit 7cfc04
#!/bin/sh
Packit 7cfc04
#
Packit 7cfc04
# find_slashes_no_parens.sh
Packit 7cfc04
#
Packit 7cfc04
# Look for function names inside \f[BI]...\f[PB] that aren't
Packit 7cfc04
# followed by "()".
Packit 7cfc04
#
Packit 7cfc04
# This script is designed to help with "by hand" tidy-ups after
Packit 7cfc04
# the automated changes made by add_parens_for_own_funcs.sh.
Packit 7cfc04
#
Packit 7cfc04
# The first argument to this script names a manual page directory where 
Packit 7cfc04
# 'man2' and 'man3' subdirectories can be found.  The pages names in 
Packit 7cfc04
# these directories are used to generate a series of regular expressions 
Packit 7cfc04
# that can be used to search the manual page files that are named in 
Packit 7cfc04
# the remaining command-line arguments.
Packit 7cfc04
#
Packit 7cfc04
# Example usage: 
Packit 7cfc04
#
Packit 7cfc04
#    cd man-pages-x.yy
Packit 7cfc04
#    sh find_slashes_no_parens.sh . man?/*.? > matches.log
Packit 7cfc04
#
Packit 7cfc04
######################################################################
Packit 7cfc04
#
Packit 7cfc04
# (C) Copyright 2005 & 2013, Michael Kerrisk
Packit 7cfc04
# This program is free software; you can redistribute it and/or
Packit 7cfc04
# modify it under the terms of the GNU General Public License
Packit 7cfc04
# as published by the Free Software Foundation; either version 2
Packit 7cfc04
# of the License, or (at your option) any later version.
Packit 7cfc04
# 
Packit 7cfc04
# This program is distributed in the hope that it will be useful,
Packit 7cfc04
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 7cfc04
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 7cfc04
# GNU General Public License for more details
Packit 7cfc04
# (http://www.gnu.org/licenses/gpl-2.0.html).
Packit 7cfc04
#
Packit 7cfc04
Packit 7cfc04
if test $# -lt 2; then
Packit 7cfc04
    echo "Usage: $0 man-page-root-dir file file..." 1>&2
Packit 7cfc04
    exit 1
Packit 7cfc04
fi
Packit 7cfc04
Packit 7cfc04
dir=$1
Packit 7cfc04
Packit 7cfc04
if ! test -d $dir/man2 || ! test -d $dir/man3; then
Packit 7cfc04
    echo "Can't find man2 and man3 under $dir" 1>&2
Packit 7cfc04
    exit 1
Packit 7cfc04
fi
Packit 7cfc04
Packit 7cfc04
shift 1
Packit 7cfc04
Packit 7cfc04
echo "This will probably take a few minutes..." 1>&2
Packit 7cfc04
Packit 7cfc04
regexp_file=tmp.$0.regexp
Packit 7cfc04
rm -f $regexp_file
Packit 7cfc04
Packit 7cfc04
# We grep out a few page names that are likely to generate false 
Packit 7cfc04
# positives...
Packit 7cfc04
Packit 7cfc04
for page in $(
Packit 7cfc04
Packit 7cfc04
	find $dir/man2/* $dir/man3/* -type f -name '*.[23]' | 
Packit 7cfc04
	egrep -v '/(stderr|stdin|stdout|errno|termios|string)\..$'); do
Packit 7cfc04
    
Packit 7cfc04
    base=$(basename $page | sed -e 's/\.[23]$//')
Packit 7cfc04
Packit 7cfc04
    echo "\\\\f[BI]$base\\\\f[PB][^(]" >> $regexp_file
Packit 7cfc04
    echo "\\\\f[BI]$base\\\\f[PB]\$" >> $regexp_file
Packit 7cfc04
done
Packit 7cfc04
Packit 7cfc04
sort -o $regexp_file $regexp_file	# Not really needed
Packit 7cfc04
Packit 7cfc04
echo "Built regexp file; now about to grep..." 1>&2
Packit 7cfc04
Packit 7cfc04
grep -f $regexp_file $*
Packit 7cfc04
Packit 7cfc04
rm -f $regexp_file
Packit 7cfc04
exit 0