Put the rsync-ssl-rsh helper script into a lib dir.
[rsync.git] / tweak_manpage
blob76b76040cbc2ea01bd647880121fd9beec722c44
1 #!/usr/bin/perl -i -p
3 use strict;
4 use warnings;
6 our %subs;
8 BEGIN {
9 open IN, '<', 'Makefile' or die $!;
10 while (<IN>) {
11 my ($var, $val) = /^(\w+)=(.+)/;
12 next unless defined $val;
13 $val =~ s/\$\{(\w+)\}/$subs{$1}/ while $val =~ /\$\{/;
14 $subs{$var} = $val;
15 last if $var eq 'libdir';
17 close IN;
20 # We only need to use "\&'" or "\&." at the start of a line.
21 s/(?<=.)\\\&(['.])/$1/g;
23 # Some quotes turn into open/close quotes.
24 s/'(.)'/\\(oq$1\\(cq/g;
25 s/(^|[ (])"(?!( |$))/$1\\(lq/gm;
26 s/(?<! )"([.,:;! )]|$)/\\(rq$1/gm;
27 s/(\\\(lq[^(]*) "( |$)/$1 \\(rq$2/gm;
28 s/(^| )" ([^(]*\\\(rq)/$1\\(lq $2/gm;
30 # And some don't.
31 s/^([. ])(.*)/ $1 . realquotes($2) /egm;
32 s/(\\f(B|\(CW).*?\\fP)/ realquotes($1) /egs;
34 s/^\\\&(\\\(oq)/$1/gm;
36 s/\@libdir\@/$subs{libdir}/g;
38 sub realquotes
40 my($txt) = @_;
41 $txt =~ s/\\\([lr]q/"/g;
42 $txt =~ s/\\\([oc]q/'/g;
43 $txt;