/[wait]/trunk/lib/WAIT/Filter.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/lib/WAIT/Filter.pm

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

revision 109 by dpavlin, Tue Jul 13 17:50:27 2004 UTC revision 118 by dpavlin, Fri Jul 15 18:59:10 2005 UTC
# Line 16  package WAIT::Filter; Line 16  package WAIT::Filter;
16  require WAIT;  require WAIT;
17  use strict;  use strict;
18  use Carp;  use Carp;
19  use vars qw($VERSION @ISA @EXPORT_OK %STOP $SPLIT $AUTOLOAD);  use vars qw($VERSION @ISA @EXPORT_OK %STOP $SPLIT $UNAC $ICONV $AUTOLOAD);
20  use subs qw(grundform);  use subs qw(grundform);
21    
22    use Text::Unaccent;
23    use Text::Iconv;
24    
25  require Exporter;  require Exporter;
26    
27  @ISA = qw(Exporter);  @ISA = qw(Exporter);
# Line 47  $SPLIT = q[ Line 50  $SPLIT = q[
50                           }                           }
51            ];            ];
52    
53    $UNAC = q[
54            sub unac_CHARSET {
55                    map split(' ',unac_string('CHARSET', $_) || $_), @_;
56            }
57    ];
58    
59    my $iconv;
60    
61    $ICONV = q[
62            sub iconv_CHARSETfrom_CHARSETto {
63                    my $ic = $iconv->{'CHARSETfrom_CHARSETto'});
64                    $ic ||= $iconv->{'CHARSETfrom_CHARSETto'} = Text::Iconv->new('CHARSETfrom','CHARSETto');
65                    map split(' ',$ic->convert($_) || $_), @_;
66            }
67    ];
68                    
69    
70  sub AUTOLOAD {  sub AUTOLOAD {
71    my $func = $AUTOLOAD; $func =~ s/.*:://;    my $func = $AUTOLOAD; $func =~ s/.*:://;
72    
# Line 73  sub AUTOLOAD { Line 93  sub AUTOLOAD {
93      goto \&date;      goto \&date;
94    } elsif ($func eq 'decode_entities') {    } elsif ($func eq 'decode_entities') {
95      eval {require HTML::Entities;};      eval {require HTML::Entities;};
96      croak "You must have HTML::Entities to use 'date'"      croak "You must have HTML::Entities to use 'decode_entities'"
97        if $@ ne '';        if $@ ne '';
98      *decode_entities = HTML::Entities->can('decode_entities');      *decode_entities = HTML::Entities->can('decode_entities');
99      goto &decode_entities;      goto &decode_entities;
# Line 87  sub AUTOLOAD { Line 107  sub AUTOLOAD {
107        $s;        $s;
108      };      };
109      goto \&$func;      goto \&$func;
110      } elsif ($func =~ /unac_(.+)/) {
111        my $charset = $1;
112        my $unac = $UNAC;
113        $unac =~ s/CHARSET/$charset/g;
114    print "### $unac ###\n";
115        eval $unac;
116        if ($@ eq '') {
117         goto &$func;
118        }
119      } elsif ($func =~ /iconv_([^_]+)_([^_]+)/) {
120        my ($cf,$ct) = ($1,$2);
121        my $iconv = $ICONV;
122    print "### $cf -> $ct\n";
123        $iconv =~ s/CHARSETfrom/$cf/gs;
124        $iconv =~ s/CHARSETto/$ct/gs;
125    print "### $iconv ###\n";
126        eval $iconv;
127        if ($@ eq '') {
128         goto &$func;
129        }
130    }    }
131    Carp::confess "Class WAIT::Filter::$func not found";    Carp::confess "Class WAIT::Filter::$func not found";
132  }  }

Legend:
Removed from v.109  
changed lines
  Added in v.118

  ViewVC Help
Powered by ViewVC 1.1.26