5 # The manual pages before 2.10 format parentheses
6 # inconsistently. In some cases they are like:
10 # while in others they are like:
14 # This script changes instances to the latter format.
15 # It does not fix all such instances: some will have to be
18 # Use the "-n" option for a dry run, in order to see what would be
19 # done, without actually doing it.
21 ######################################################################
23 # (C) Copyright 2005 & 2013, Michael Kerrisk
24 # This program is free software; you can redistribute it and/or
25 # modify it under the terms of the GNU General Public License
26 # as published by the Free Software Foundation; either version 2
27 # of the License, or (at your option) any later version.
29 # This program is distributed in the hope that it will be useful,
30 # but WITHOUT ANY WARRANTY; without even the implied warranty of
31 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 # GNU General Public License for more details
33 # (http://www.gnu.org/licenses/gpl-2.0.html).
37 file_base
="tmp.$(basename $0)"
39 work_dst_file
="$file_base.dst"
40 work_src_file
="$file_base.src"
42 all_files
="$work_dst_file $work_src_file"
44 # Command-line option processing
47 while getopts "n" optname
; do
51 *) echo "Unknown option: $OPTARG"
57 shift $
(( $OPTIND - 1 ))
59 # Only process files with > 1 line -- single-line files are link files
61 for page
in $
(wc "$@" 2> /dev
/null |
awk '$1 > 1 {print $4}'| \
64 cp $page $work_dst_file
66 echo ">>>>>>>>>>>>>>>>>>>>>>>>>" $page "<<<<<<<<<<<<<<<<<<<<<<<<<"
69 grep '^\.I *[a-z0-9_][a-z0-9_]*()$' $page
70 grep '^\.B *[a-z0-9_][a-z0-9_]*()$' $page
72 grep '^\.[BIR][BIR] *[a-z0-9_][a-z0-9_]*()$' $page
74 grep '^\.[BIR][BIR] *[a-z0-9_][a-z0-9_]*() [^"]*$' $page
76 grep '()\\f[PR]' $page
80 cp $work_dst_file $work_src_file
81 cat $work_src_file | \
83 -e '/^\.B *[a-z0-9_][a-z0-9_]*() *$/s/^\.B/.BR/' \
84 -e '/^\.I *[a-z0-9_][a-z0-9_]*() *$/s/^\.I/.IR/' \
87 cp $work_dst_file $work_src_file
88 cat $work_src_file | \
90 -e '/^\.[BIR][BIR] *[a-z0-9_][a-z0-9_]*()$/s/()/ ()/' \
93 cp $work_dst_file $work_src_file
94 cat $work_src_file | \
96 -e '/^\.[BIR][BIR] *[a-z0-9_][a-z0-9_]*() [^"]*$/s/() / ()/' \
99 cp $work_dst_file $work_src_file
100 cat $work_src_file | \
102 -e '/()\\fP/s/()\\fP/\\fP()/g' \
103 -e '/()\\fR/s/()\\fR/\\fR()/g' \
106 if ! cmp -s $page $work_dst_file; then
107 diff -u $page $work_dst_file
109 if test $really_do_it -ne 0; then
110 cat $work_dst_file > $page
114 echo "### NOTHING CHANGED"