/[webpac2]/trunk/lib/WebPAC/Normalize.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/Normalize.pm

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

revision 372 by dpavlin, Sun Jan 8 21:50:34 2006 UTC revision 397 by dpavlin, Wed Feb 15 15:54:12 2006 UTC
# Line 204  sub data_structure { Line 204  sub data_structure {
204                          }                          }
205                          if (! @v) {                          if (! @v) {
206                                  $log->debug("$field <",$self->{tag},"> format: $format no values");                                  $log->debug("$field <",$self->{tag},"> format: $format no values");
207  #                               next;                                  next;
208                          } else {                          } else {
209                                  $log->debug("$field <",$self->{tag},"> format: $format values: ", join(",", @v));                                  $log->debug("$field <",$self->{tag},"> format: $format values: ", join(",", @v));
210                          }                          }
# Line 471  sub fill_in { Line 471  sub fill_in {
471          # remove filter{...} from beginning          # remove filter{...} from beginning
472          $filter_name = $1 if ($format =~ s/^filter{([^}]+)}//s);          $filter_name = $1 if ($format =~ s/^filter{([^}]+)}//s);
473    
474          # do actual replacement of placeholders          {
475          # repeatable fields                  # fix warnings
476          if ($format =~ s/v(\d+)(?:\^(\w))?/$self->get_data(\$rec,$1,$2,$i,\$found,$rec_size)/ges) {                  no warnings 'uninitialized';
477                  $just_single = 0;  
478          }                  # do actual replacement of placeholders
479                    # repeatable fields
480                    if ($format =~ s/v(\d+)(?:\^(\w))?/$self->get_data(\$rec,$1,$2,$i,\$found,$rec_size)/ges) {
481                            $just_single = 0;
482                    }
483    
484          # non-repeatable fields                  # non-repeatable fields
485          if ($format =~ s/s(\d+)(?:\^(\w))?/$self->get_data(\$rec,$1,$2,0,\$found,$rec_size)/ges) {                  if ($format =~ s/s(\d+)(?:\^(\w))?/$self->get_data(\$rec,$1,$2,0,\$found,$rec_size)/ges) {
486                  return if ($i > 0 && $just_single);                          return if ($i > 0 && $just_single);
487                    }
488          }          }
489    
490          if ($found) {          if ($found) {
# Line 532  sub _rec_to_arr { Line 537  sub _rec_to_arr {
537          $log->logconfess("need HASH as first argument!") if ($rec !~ /HASH/o);          $log->logconfess("need HASH as first argument!") if ($rec !~ /HASH/o);
538          return if (! $format_utf8);          return if (! $format_utf8);
539    
540            $log->debug("using $code on $format_utf8");
541    
542          my $i = 0;          my $i = 0;
543          my $max = 0;          my $max = 0;
544          my @arr;          my @arr;
545          my $rec_size = {};          my $rec_size = {};
546    
547          while ($i <= $max) {          while ($i <= $max) {
548                  my $v = $self->$code($rec,$format_utf8,$i++,\$rec_size) || next;                  my @v = $self->$code($rec,$format_utf8,$i++,\$rec_size);
                 push @arr, $v;  
549                  if ($rec_size) {                  if ($rec_size) {
550                          foreach my $f (keys %{ $rec_size }) {                          foreach my $f (keys %{ $rec_size }) {
551                                  $max = $rec_size->{$f} if ($rec_size->{$f} > $max);                                  $max = $rec_size->{$f} if ($rec_size->{$f} > $max);
552                          }                          }
553                          warn "max set to $max, rec_size = ", Dumper($rec_size);                          $log->debug("max set to $max");
554                          undef $rec_size;                          undef $rec_size;
555                  }                  }
556                    if (@v) {
557                            push @arr, @v;
558                    } else {
559                            push @arr, '' if ($max > $i);
560                    }
561          }          }
562    
563          $log->debug("format '$format_utf8' returned ",--$i," elements: ", sub { join(" | ",@arr) }) if (@arr);          $log->debug("format '$format_utf8' returned ",--$i," elements: ", sub { join(" | ",@arr) }) if (@arr);

Legend:
Removed from v.372  
changed lines
  Added in v.397

  ViewVC Help
Powered by ViewVC 1.1.26