$left = 0;
$bits = -$bits;
}
- $bits = $length if $bits > $length;
- $length -= $bits;
- if ($left) {
- vcopy($_[0], $start, $_[0], $start + $bits, $length);
- vfill($_[0], $start, $bits, $insert) if defined $insert;
+ if ($bits < $length) {
+ $length -= $bits;
+ if ($left) {
+ vcopy($_[0], $start, $_[0], $start + $bits, $length);
+ vfill($_[0], $start, $bits, $insert) if defined $insert;
+ } else {
+ vcopy($_[0], $start + $bits, $_[0], $start, $length);
+ vfill($_[0], $start + $length, $bits, $insert) if defined $insert;
+ }
} else {
- vcopy($_[0], $start + $bits, $_[0], $start, $length);
- vfill($_[0], $start + $length, $bits, $insert) if defined $insert;
+ vfill($_[0], $start, $length, $insert) if defined $insert;
}
}
}
}
+sub expect {
+ (undef, my $s, my $l, my $b, my $left, my $insert) = @_;
+ myfill($_[0], 0, $s, 0);
+ if ($b < $l) {
+ if ($left) {
+ myfill($_[0], $s, $b, defined $insert ? $insert : 1);
+ myfill($_[0], $s + $b, $l - $b, 1);
+ } else {
+ myfill($_[0], $s, $l - $b, 1);
+ myfill($_[0], $s + $l - $b, $b, defined $insert ? $insert : 1);
+ }
+ } else {
+ myfill($_[0], $s, $l, defined $insert ? $insert : 1);
+ }
+}
+
my ($v, $v0, $c) = ('', '') x 2;
sub try {
for my $s (@s) {
for my $l (0 .. $n - 1) {
last if $s + $l > $n;
+ rst $v0;
pat $v0, $s, $l, 0;
my @b = (0);
my $l2 = int($l/2);
push @b, $l2 if $l2 != $l;
- push @b, $l if $l;
+ push @b, $l + 1;
for my $b (@b) {
$v = $v0;
- $c = '';
- myfill($c, 0, $s, 0);
- if ($left) {
- myfill($c, $s, $b, defined $insert ? $insert : 1);
- myfill($c, $s + $b, $l - $b, 1);
- } else {
- myfill($c, $s, $l - $b, 1);
- myfill($c, $s + $l - $b, $b, defined $insert ? $insert : 1);
- }
+ rst $c;
+ expect $c, $s, $l, $b, $left, $insert;
$b = -$b unless $left;
vshift $v, $s, $l => $b, $insert;
my $i = defined $insert ? $insert : 'undef';