X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=contrib%2Frestore.pl;fp=contrib%2Frestore.pl;h=f9c55ce06320dbe63e7434661819a59ae3e7ac12;hb=ab51d5778a1f19c204c935de231737df2e62c20c;hp=96cf4b47442d8efc2f56e630431f566dca3c01f0;hpb=2fc79690f0e5066b689746b18d42b95eca48a0ab;p=cumulus.git diff --git a/contrib/restore.pl b/contrib/restore.pl index 96cf4b4..f9c55ce 100755 --- a/contrib/restore.pl +++ b/contrib/restore.pl @@ -88,8 +88,8 @@ sub load_ref { my $ref_str = shift; # Check for special objects before attempting general parsing. - if ($ref_str =~ m/^zero\[(\d+)\+(\d+)\]$/) { - return "\0" x ($2 + 0); + if ($ref_str =~ m/^zero\[((\d+)\+)?(\d+)\]$/) { + return "\0" x ($3 + 0); } # Try to parse the object reference string into constituent pieces. The @@ -122,12 +122,17 @@ sub load_ref { # If a range was specified, then only a subset of the bytes of the object # are desired. Extract just the desired bytes. if ($range) { - if ($range !~ m/^\[(\d+)\+(\d+)\]$/) { + if ($range !~ m/^\[((\d+)\+)?(\d+)\]$/) { die "Malformed object range: $range"; } my $object_size = length $contents; - my ($start, $length) = ($1 + 0, $2 + 0); + my ($start, $length); + if ($1 ne "") { + ($start, $length) = ($2 + 0, $3 + 0); + } else { + ($start, $length) = (0, $3 + 0); + } if ($start >= $object_size || $start + $length > $object_size) { die "Object range $range falls outside object bounds " . "(actual size $object_size)";