my $input_encoding = $arg->{'input_encoding'} || $self->{'input_encoding'} || 'cp852';
# store data in object
- foreach my $v (qw/path offset limit/) {
- $self->{$v} = $arg->{$v} if defined $arg->{$v};
- }
+ $self->{$_} = $arg->{$_} foreach grep { defined $arg->{$_} } qw(path offset limit);
if ($arg->{load_row} || $arg->{save_row}) {
$log->logconfess("save_row and load_row must be defined in pair and be CODE") unless (
$to_rec = $size if ($to_rec > $size);
}
- # store size for later
- $self->{size} = $to_rec - $from_rec + 1;
-
my $strict_encoding = $arg->{strict_encoding} || $self->{strict_encoding}; ## FIXME should be 1 really
$log->info("processing $self->{size}/$size records [$from_rec-$to_rec]",
$self->{stats} ? ' [stats]' : '',
);
+ $self->{size} = 0;
+
# read database
for (my $pos = $from_rec; $pos <= $to_rec; $pos++) {
$log->debug("position: $pos\n");
+ $self->{size}++; # XXX I could move this more down if I didn't want empty records...
+
my $rec = $ll_db->fetch_rec($pos, sub {
my ($l,$f_nr,$debug) = @_;
# return unless defined($l);
sub size {
my $self = shift;
- $self->{ll_db}->size if $self->{ll_db}->can('size');
return $self->{size}; # FIXME this is buggy if open is called multiple times!
}
cmp_ok($input->size, '==', $e, "input->size = $e");
}
-test_start_limit($input, 1, 3, 3);
-test_start_limit($input, $size, 3, 0);
+test_start_limit($input, 1, 0, $size - 1);
+test_start_limit($input, $size, 0, 0);
test_start_limit($input, 3, $size, $size - 3);
test_start_limit($input, 1, $size, $size - 1);