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

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

trunk/parse_format.pm revision 170 by dpavlin, Sun Nov 23 15:42:16 2003 UTC branches/hidra/parse_format.pm revision 260 by dpavlin, Thu Mar 11 20:32:55 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 80  sub parse_iso_format { Line 83  sub parse_iso_format {
83                          # this might be our local scpeciality -- fields 10 and 11                          # this might be our local scpeciality -- fields 10 and 11
84                          # (as opposed to 010 and 011) so they are strictly listed                          # (as opposed to 010 and 011) so they are strictly listed
85                          # here                          # here
86                          } elsif ($f =~ s/^(1[01])//) {                          } elsif ($f =~ s/^(1[01]\w?)//) {
87                                  push @fmt,$1;                                  push @fmt,$1;
88                                  push @fmt,undef;                                  push @fmt,undef;
89                          } elsif ($f =~ s/^mfn//i) {                          } elsif ($f =~ s/^mfn//i) {
90                                  push @fmt,'mfn';                                  push @fmt,'mfn';
91                                  push @fmt,'';                                  push @fmt,'';
92                          } elsif ($f =~ s/^([^\d]+)(\d{0,3})/$2/) {                          } elsif ($f =~ s/^([^\d]+)(\d{0,3})/$2/) {
93                                  push @fmt,$1;                                  # still prefix?
94                                    if ($#fmt == 0) {
95                                            $fmt[0] .= $1;
96                                    } else {
97                                            push @fmt,$1;
98                                    }
99                          } elsif ($f =~ s/^([^\d]+\d{0,2})//) {                          } elsif ($f =~ s/^([^\d]+\d{0,2})//) {
100                                  push @fmt,$1;                                  if ($#fmt == 0) {
101                                            $fmt[0] .= $1;
102                                    } else {
103                                            push @fmt,$1;
104                                    }
105                          } elsif ($f =~ s/^(\d{1,2})//) {                          } elsif ($f =~ s/^(\d{1,2})//) {
106                                  push @fmt,$1;                                  if ($#fmt == 0) {
107                                            $fmt[0] .= $1;
108                                    } else {
109                                            push @fmt,$1;
110                                    }
111                          } else {                          } else {
112                                  print STDERR "unparsed format: $f\n";                                  print STDERR "unparsed format: $f\n";
113                                  $f = "";                                  $f = "";
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 138  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 "display: $display swish: $swish\n";          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";
185    
186          return ($swish,$display);          return ($swish,$display);
187  }  }

Legend:
Removed from v.170  
changed lines
  Added in v.260

  ViewVC Help
Powered by ViewVC 1.1.26