r349@llin: dpavlin | 2006-01-02 12:02:07 +0100
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 2 Jan 2006 10:58:26 +0000 (10:58 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 2 Jan 2006 10:58:26 +0000 (10:58 +0000)
 fixed s999 fields

git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@340 07558da8-63fa-0310-ba24-9fe276d99e06

lib/WebPAC/Normalize.pm

index 77e17f8..847865a 100644 (file)
@@ -317,7 +317,7 @@ sub parse {
 
        my @out;
 
-       $log->debug("format: $format");
+       $log->debug("format: $format [$i]");
 
        my $eval_code;
        # remove eval{...} from beginning
@@ -328,7 +328,7 @@ sub parse {
        $filter_name = $1 if ($format =~ s/^filter{([^}]+)}//s);
 
        # did we found any (att all) field from format in row?
-       my $found_any = 0;
+       my $found_any;
        # prefix before first field which we preserve it $found_any
        my $prefix;
 
@@ -339,15 +339,23 @@ sub parse {
                my $del = $1 || '';
                $prefix = $del if ($f_step == 1);
 
+               my $fld_type = lc($2);
+
                # repeatable index
                my $r = $i;
-               $r = 0 if (lc("$2") eq 's');
+               if ($fld_type eq 's') {
+                       if ($found_any->{'v'}) {
+                               $r = 0;
+                       } else {
+                               return;
+                       }
+               }
 
                my $found = 0;
                my $tmp = $self->get_data(\$rec,$3,$4,$r,\$found);
 
                if ($found) {
-                       $found_any += $found;
+                       $found_any->{$fld_type} += $found;
 
                        # we will skip delimiter before first occurence of field!
                        push @out, $del unless($found_any == 1);
@@ -356,7 +364,8 @@ sub parse {
                $f_step++;
        }
 
-       return if (! $found_any);
+       # test if any fields found?
+       return if (! $found_any->{'v'} && ! $found_any->{'s'});
 
        my $out = join('',@out);