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

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

revision 10 by dpavlin, Thu Jan 16 17:35:54 2003 UTC revision 46 by dpavlin, Sun Mar 23 01:14:59 2003 UTC
# Line 6  Line 6 
6  use isis_sf;  use isis_sf;
7    
8  sub parse_format {  sub parse_format {
9          my $format = shift;          my $format = shift || die "parse_format must be called with format!";
10          my $row = shift;          my $row = shift || die "parse_format must be called with row!";
11            my $i = shift || 0;     # isis repeatable number
12            my $codepage = shift || die "parse_format must be called with codepage!";
13    
14          my $out;          my $out;
15          my $out_swish;          my $out_swish;
16    
17          my $prefix = "";          my $prefix = "";
18          if ($format =~ s/^([^\d]+)//) {          if ($format =~ s/^([^\d]+)//) {
19                  $prefix = "pre: $1";                  $prefix = $1;
20          }          }
21    
22          my $display;          my $display;
23          my $swish;          my $swish;
24    
25          while ($format) {          while ($format) {
26  #print STDERR "#### $format\n";  #print STDERR "\n#### $format";
27                  if ($format =~ s/^(\d\d\d)(\w?)//) {                  if ($format =~ s/^(\d\d\d)(\w?)//) {
28                          my $isis_tmp = isis_sf($row,$1,$2);                          my $isis_tmp = isis_sf($row,$1,$2,$i);
29                          if ($isis_tmp) {                          if ($isis_tmp) {
30                                    $isis_tmp = $codepage->convert($isis_tmp) if ($codepage);
31                                  $display .= $prefix . $isis_tmp;                                  $display .= $prefix . $isis_tmp;
32                                  $swish .= $isis_tmp." ";                                  $swish .= $isis_tmp." ";
33    #print STDERR " == $isis_tmp";
34                          }                          }
35                          $prefix = "";                          $prefix = "";
36                    # this might be our local scpeciality -- fields 10 and 11
37                    # (as opposed to 010 and 011) so they are strictly listed
38                    # here
39                    } elsif ($format =~ s/^(1[01])//) {
40                            my $isis_tmp = isis_sf($row,$1,undef,$i);
41                            if ($isis_tmp) {
42                                    $isis_tmp = $codepage->convert($isis_tmp) if ($codepage);
43                                    $display .= $prefix . $isis_tmp;
44                                    $swish .= $isis_tmp." ";
45                            }
46                            $prefix = "";
47                    } elsif ($format =~ s/^mfn//i) {
48                            $display .= $prefix . $row->{mfn};
49                            $prefix = "";
50                  } elsif ($format =~ s/^([^\d]+)(\d{0,3})/$2/) {                  } elsif ($format =~ s/^([^\d]+)(\d{0,3})/$2/) {
51                          $prefix .= $1;                          $prefix .= $1 if ($display);
52                  } elsif ($format =~ s/^([^\d]+\d{0,2})//) {                  } elsif ($format =~ s/^([^\d]+\d{0,2})//) {
53                          $prefix .= $1;                          $prefix .= $1 if ($display);
54                  } elsif ($format =~ s/^(\d{1,2})//) {                  } elsif ($format =~ s/^(\d{1,2})//) {
55                          $prefix .= $1;                          $prefix .= $1 if ($display);
56                  } else {                  } else {
57                          print STDERR "unparsed format: $format\n";                          print STDERR "unparsed format: $format\n";
58                          $prefix .= $format;                          $prefix .= $format;

Legend:
Removed from v.10  
changed lines
  Added in v.46

  ViewVC Help
Powered by ViewVC 1.1.26