/[webpac2]/trunk/lib/WebPAC/Input.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WebPAC/Input.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1306 by dpavlin, Mon Sep 21 15:48:52 2009 UTC revision 1307 by dpavlin, Mon Sep 21 16:42:25 2009 UTC
# Line 182  sub open { Line 182  sub open {
182          my $input_encoding = $arg->{'input_encoding'} || $self->{'input_encoding'} || 'cp852';          my $input_encoding = $arg->{'input_encoding'} || $self->{'input_encoding'} || 'cp852';
183    
184          # store data in object          # store data in object
185          foreach my $v (qw/path offset limit/) {          $self->{$_} = $arg->{$_} foreach grep { defined $arg->{$_} } qw(path offset limit);
                 $self->{$v} = $arg->{$v} if defined $arg->{$v};  
         }  
186    
187          if ($arg->{load_row} || $arg->{save_row}) {          if ($arg->{load_row} || $arg->{save_row}) {
188                  $log->logconfess("save_row and load_row must be defined in pair and be CODE") unless (                  $log->logconfess("save_row and load_row must be defined in pair and be CODE") unless (
# Line 276  sub open { Line 274  sub open {
274                  $to_rec = $size if ($to_rec > $size);                  $to_rec = $size if ($to_rec > $size);
275          }          }
276    
         # store size for later  
         $self->{size} = $to_rec - $from_rec + 1;  
   
277          my $strict_encoding = $arg->{strict_encoding} || $self->{strict_encoding}; ## FIXME should be 1 really          my $strict_encoding = $arg->{strict_encoding} || $self->{strict_encoding}; ## FIXME should be 1 really
278    
279          $log->info("processing $self->{size}/$size records [$from_rec-$to_rec]",          $log->info("processing $self->{size}/$size records [$from_rec-$to_rec]",
# Line 286  sub open { Line 281  sub open {
281                  $self->{stats} ? ' [stats]' : '',                  $self->{stats} ? ' [stats]' : '',
282          );          );
283    
284            $self->{size} = 0;
285    
286          # read database          # read database
287          for (my $pos = $from_rec; $pos <= $to_rec; $pos++) {          for (my $pos = $from_rec; $pos <= $to_rec; $pos++) {
288    
289                  $log->debug("position: $pos\n");                  $log->debug("position: $pos\n");
290    
291                    $self->{size}++; # XXX I could move this more down if I didn't want empty records...
292    
293                  my $rec = $ll_db->fetch_rec($pos, sub {                  my $rec = $ll_db->fetch_rec($pos, sub {
294                                  my ($l,$f_nr,$debug) = @_;                                  my ($l,$f_nr,$debug) = @_;
295  #                               return unless defined($l);  #                               return unless defined($l);
# Line 473  because it takes into account C<offset> Line 472  because it takes into account C<offset>
472    
473  sub size {  sub size {
474          my $self = shift;          my $self = shift;
         $self->{ll_db}->size if $self->{ll_db}->can('size');  
475          return $self->{size}; # FIXME this is buggy if open is called multiple times!          return $self->{size}; # FIXME this is buggy if open is called multiple times!
476  }  }
477    

Legend:
Removed from v.1306  
changed lines
  Added in v.1307

  ViewVC Help
Powered by ViewVC 1.1.26