/[webpac]/trunk2/parse_format.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 /trunk2/parse_format.pm

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

revision 187 by dpavlin, Sat Nov 29 18:58:34 2003 UTC revision 263 by dpavlin, Fri Mar 12 15:06:58 2004 UTC
# Line 55  sub parse_iso_format { Line 55  sub parse_iso_format {
55    
56                  my $f = $format;                  my $f = $format;
57    
58                    my $eval;
59                    $eval = $1 if ($f =~ s/^eval{([^}]+)}//);
60    
61                  if ($f =~ s/^([^\d]+)//) {                  if ($f =~ s/^([^\d]+)//) {
62                          if ($f) {       # there is more to parse                          if ($f) {       # there is more to parse
63                                  push @fmt,$1;                                  push @fmt,$1;
# Line 111  sub parse_iso_format { Line 114  sub parse_iso_format {
114                          }                          }
115                  }                  }
116                  push @fmt,'' if ($#fmt % 3 != 0);       # add empty suffix                  push @fmt,'' if ($#fmt % 3 != 0);       # add empty suffix
117    
118                    $cache->{format_eval}->{$format} = $eval; # store eval string (if any)
119    
120                  $cache->{format}->{$format} = \@fmt;                  $cache->{format}->{$format} = \@fmt;
121                                    
122  #               print STDERR "storing format for '$format': [",join("|",@fmt),"]\n";  #               print STDERR "storing format for '$format': [",join("|",@fmt),"]\n";
# Line 151  sub parse_iso_format { Line 157  sub parse_iso_format {
157                  $sufix = shift @fmt;                  $sufix = shift @fmt;
158          }          }
159          $display = $prefix.$display.$sufix if ($display);          $display = $prefix.$display.$sufix if ($display);
         print STDERR "format left unused: [",join("|",@fmt),"]\n" if (@fmt);  
160    
161          print STDERR "format: [",join("|",@{$tmp}),"]\n" if (@fmt);          my $eval = $cache->{format_eval}->{$format};
162            if ($eval) {
163                    sub fld2str {
164                            my ($func,$row,$f,$sf,$i) = @_;
165    #print STDERR "## in fld2str\n";
166                            my $tmp = &$func($row,$f,$sf,$i) || '';
167                            return "'$tmp'";
168                    }
169    
170                    $eval =~ s/v(\d+)\^(\w*)/fld2str($func,$row,$1,$2,$i)/eg;
171    #print STDERR "## eval: $eval\n";
172                    if (eval "$eval") {
173                            return ($swish,$display);
174                    } else {
175                            return (undef,undef);
176                    }
177            }
178    
179            if (@fmt) {
180                    print STDERR "format left unused: [",join("|",@fmt),"]\n";
181                    print STDERR "format: [",join("|",@{$tmp}),"]\n";
182            }
183    
184  #       print STDERR "format: {",$format || '',"} display: {",$display || '',"} swish: {",$swish || '',"}\n";  #       print STDERR "format: {",$format || '',"} display: {",$display || '',"} swish: {",$swish || '',"}\n";
185    

Legend:
Removed from v.187  
changed lines
  Added in v.263

  ViewVC Help
Powered by ViewVC 1.1.26