]>
git.ipfire.org Git - thirdparty/man-pages.git/blob - scripts/unformat_parens.sh
5 # The manual pages before 2.10 treat 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 ######################################################################
24 file_base
="tmp.$(basename $0)"
26 work_dst_file
="$file_base.dst"
27 work_src_file
="$file_base.src"
29 all_files
="$work_dst_file $work_src_file"
31 # Command-line option processing
34 while getopts "n" optname
; do
38 *) echo "Unknown option: $OPTARG"
44 shift $
(( OPTIND
- 1 ))
46 # Only process files with > 1 line -- single-line files are link files
48 for page
in $
(wc $
* 2> /dev
/null |
awk '$1 > 1 {print $4}'| \
51 cp $page $work_dst_file
53 echo ">>>>>>>>>>>>>>>>>>>>>>>>>" $page "<<<<<<<<<<<<<<<<<<<<<<<<<"
56 grep '^\.I *[a-z0-9_][a-z0-9_]*()$' $page
57 grep '^\.B *[a-z0-9_][a-z0-9_]*()$' $page
59 grep '^\.[BIR][BIR] *[a-z0-9_][a-z0-9_]*()$' $page
61 grep '^\.[BIR][BIR] *[a-z0-9_][a-z0-9_]*() [^"]*$' $page
63 grep '()\\f[PR]' $page
67 cp $work_dst_file $work_src_file
68 cat $work_src_file | \
70 -e '/^\.B *[a-z0-9_][a-z0-9_]*() *$/s/^\.B/.BR/' \
71 -e '/^\.I *[a-z0-9_][a-z0-9_]*() *$/s/^\.I/.IR/' \
74 cp $work_dst_file $work_src_file
75 cat $work_src_file | \
77 -e '/^\.[BIR][BIR] *[a-z0-9_][a-z0-9_]*()$/s/()/ ()/' \
80 cp $work_dst_file $work_src_file
81 cat $work_src_file | \
83 -e '/^\.[BIR][BIR] *[a-z0-9_][a-z0-9_]*() [^"]*$/s/() / ()/' \
86 cp $work_dst_file $work_src_file
87 cat $work_src_file | \
89 -e '/()\\fP/s/()\\fP/\\fP()/g' \
90 -e '/()\\fR/s/()\\fR/\\fR()/g' \
93 if ! cmp -s $page $work_dst_file; then
94 diff -u $page $work_dst_file
96 if test $really_do_it -ne 0; then
97 cat $work_dst_file > $page
101 echo "### NOTHING CHANGED"