Commit b8a47c9b authored by Wayne Davison's avatar Wayne Davison

- Fixed a bug where the --*-dest options weren't being culled.

- Simplified the output format by putting all the long-name
  options into a single hash.
parent 85fbfa10
...@@ -3,10 +3,8 @@ ...@@ -3,10 +3,8 @@
# that the code in options.c might send to the server. This perl code # that the code in options.c might send to the server. This perl code
# is included in the rrsync script. # is included in the rrsync script.
use strict; use strict;
no strict 'refs';
our(%short_no_arg, %short_with_num); our(%short_no_arg, %short_with_num, %long_opt);
our(%long_no_arg, %long_before_arg, %long_with_arg);
our $last_long_opt; our $last_long_opt;
open(IN, '../options.c') or die "Unable to open ../options.c: $!\n"; open(IN, '../options.c') or die "Unable to open ../options.c: $!\n";
...@@ -20,17 +18,16 @@ while (<IN>) { ...@@ -20,17 +18,16 @@ while (<IN>) {
undef $last_long_opt; undef $last_long_opt;
} elsif (/\Qargs[ac++]\E = "--([^"=]+)"/) { } elsif (/\Qargs[ac++]\E = "--([^"=]+)"/) {
$last_long_opt = $1; $last_long_opt = $1;
$long_no_arg{$1} = 1; $long_opt{$1} = 0;
} elsif (defined($last_long_opt) } elsif (defined($last_long_opt)
&& /\Qargs[ac++]\E = ([^["\s]+);/ && $1 ne 'dest_option') { && /\Qargs[ac++]\E = ([^["\s]+);/ && $1 ne 'dest_option') {
delete $long_no_arg{$last_long_opt}; $long_opt{$last_long_opt} = 2;
$long_before_arg{$last_long_opt} = 1;
undef $last_long_opt; undef $last_long_opt;
} elsif (/dest_option = "--([^"])"/) { } elsif (/dest_option = "--([^"]+)"/) {
$long_before_arg{$1} = 1; $long_opt{$1} = 2;
undef $last_long_opt; undef $last_long_opt;
} elsif (/\Qasprintf(\E[^,]+, "--([^"=]+)=/ || /\Qargs[ac++]\E = "--([^"=]+)=/) { } elsif (/\Qasprintf(\E[^,]+, "--([^"=]+)=/ || /\Qargs[ac++]\E = "--([^"=]+)=/) {
$long_with_arg{$1} = 1; $long_opt{$1} = 1;
undef $last_long_opt; undef $last_long_opt;
} }
} }
...@@ -50,23 +47,18 @@ our \$short_disabled = ''; ...@@ -50,23 +47,18 @@ our \$short_disabled = '';
our \$short_no_arg = '$short_no_arg'; # DO NOT REMOVE ANY our \$short_no_arg = '$short_no_arg'; # DO NOT REMOVE ANY
our \$short_with_num = '$short_with_num'; # DO NOT REMOVE ANY our \$short_with_num = '$short_with_num'; # DO NOT REMOVE ANY
# To disable a long-named option, change its value to a 0 (NOTE: at least # To disable a long-named option, change its value to a -1. The values mean:
# one option appears in two places!). A value of -1 means the arg doesn't # 0 = the option has no arg; 1 = the arg doesn't need any checking; 2 = only
# need checking, a 1 means to check it, a 2 means only check when receiving. # check the arg when receiving; and 3 = always check the arg.
our \%long_opt = (
EOT EOT
foreach my $name (qw( long_no_arg long_with_arg long_before_arg )) { foreach my $opt (sort keys %long_opt) {
$_ = "our \%$name = (\n '" . join("' => 1,\n '", sort keys %$name) . "' => 1,\n);\n"; my $val = $long_opt{$opt};
if ($name eq 'long_before_arg') { $val = 1 if $opt =~ /^max-/;
s/ 1,/ 2,/g; $val = 3 if $opt eq 'files-from';
s/('files-from' =>) 2,/$1 1,/; $val = '$ro ? -1 : ' . $val if $opt =~ /^remove-/;
s/('max-.* =>) 2,/$1 -1,/g; print " '$opt' => $val,\n";
} else {
s/ 1,/ -1,/g;
s/('files-from' =>) -1,/$1 1,/;
}
s/('remove-.* =>) (-?\d),/$1 \$ro ? 0 : $2,/g;
print;
} }
print "\n"; print ");\n\n";
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment