/[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

Annotation of /trunk/parse_format.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 43 - (hide annotations)
Sat Mar 22 22:43:05 2003 UTC (16 years, 8 months ago) by dpavlin
File size: 2106 byte(s)
fixed alphabet soup -- characters encoding should really work now!

1 dpavlin 10 #-------------------------------------------------------------
2     #
3     # parse_format('format',$isis_row);
4     #
5    
6     use isis_sf;
7    
8     sub parse_format {
9 dpavlin 43 my $format = shift || die "parse_format must be called with format!";
10     my $row = shift || die "parse_format must be called with row!";
11 dpavlin 23 my $i = shift || 0; # isis repeatable number
12 dpavlin 43 my $codepage = shift || die "parse_format must be called with codepage!";
13 dpavlin 10
14     my $out;
15     my $out_swish;
16    
17     my $prefix = "";
18     if ($format =~ s/^([^\d]+)//) {
19 dpavlin 23 $prefix = $1;
20 dpavlin 10 }
21    
22     my $display;
23     my $swish;
24    
25     while ($format) {
26 dpavlin 23 #print STDERR "\n#### $format";
27 dpavlin 10 if ($format =~ s/^(\d\d\d)(\w?)//) {
28 dpavlin 23 my $isis_tmp = isis_sf($row,$1,$2,$i);
29 dpavlin 10 if ($isis_tmp) {
30 dpavlin 43 eval {
31     $isis_tmp = $codepage->convert($isis_tmp) if ($codepage);
32     };
33     if ($@) {
34     print STDERR "FATAL: something bad happend while trying to convert '$isis_tmp' [mfn: ",$row->{mfn},"]\n"
35     }
36 dpavlin 10 $display .= $prefix . $isis_tmp;
37     $swish .= $isis_tmp." ";
38 dpavlin 23 #print STDERR " == $isis_tmp";
39 dpavlin 10 }
40     $prefix = "";
41 dpavlin 22 # this might be our local scpeciality -- fields 10 and 11
42     # (as opposed to 010 and 011) so they are strictly listed
43     # here
44     } elsif ($format =~ s/^(1[01])//) {
45 dpavlin 23 my $isis_tmp = isis_sf($row,$1,undef,$i);
46 dpavlin 22 if ($isis_tmp) {
47 dpavlin 43 eval {
48     $isis_tmp = $codepage->convert($isis_tmp) if ($codepage);
49     };
50     if ($@) {
51     print STDERR "FATAL: something bad happend while trying to convert '$isis_tmp' [mfn: ",$row->{mfn},"]\n"
52     }
53 dpavlin 22 $display .= $prefix . $isis_tmp;
54     $swish .= $isis_tmp." ";
55     }
56     $prefix = "";
57 dpavlin 23 } elsif ($format =~ s/^mfn//i) {
58     $display .= $prefix . $row->{mfn};
59     $prefix = "";
60 dpavlin 10 } elsif ($format =~ s/^([^\d]+)(\d{0,3})/$2/) {
61 dpavlin 23 $prefix .= $1 if ($display);
62 dpavlin 10 } elsif ($format =~ s/^([^\d]+\d{0,2})//) {
63 dpavlin 23 $prefix .= $1 if ($display);
64 dpavlin 10 } elsif ($format =~ s/^(\d{1,2})//) {
65 dpavlin 23 $prefix .= $1 if ($display);
66 dpavlin 10 } else {
67     print STDERR "unparsed format: $format\n";
68     $prefix .= $format;
69     $format = "";
70     }
71     }
72     # add suffix
73     $display .= $prefix if ($display);
74    
75     return ($swish,$display);
76     }
77    
78     #-------------------------------------------------------------
79     1;

Properties

Name Value
cvs2svn:cvs-rev 1.5

  ViewVC Help
Powered by ViewVC 1.1.26