fix filter error handling and error counting
[spider.git] / perl / Filter.pm
index 37d9de6c2ed13551d1e7950b73e753b67a29d36a..10021a4eada0e886660e65b44e699451bd8fb452 100644 (file)
@@ -10,7 +10,7 @@
 #
 # Copyright (c) 1999 Dirk Koopman G1TLH
 #
-# $Id$
+#
 #
 # The NEW INSTRUCTIONS
 #
@@ -30,6 +30,9 @@ use DXVars;
 use DXUtil;
 use DXDebug;
 use Data::Dumper;
+use Prefix;
+use DXLog;
+use DXJSON;
 
 use strict;
 
@@ -37,11 +40,13 @@ use vars qw ($filterbasefn $in);
 
 $filterbasefn = "$main::root/filter";
 $in = undef;
+my $json;
+
 
 # initial filter system
 sub init
 {
-
+       $json = DXJSON->new->indent(1);
 }
 
 sub new
@@ -76,6 +81,30 @@ sub getfn
 # in with a 'do' statement. The 'do' statement reads the filter into
 # @in which is a list of references
 #
+sub compile
+{
+       my $self = shift;
+       my $fname = shift;
+       my $ar = shift;
+       my $ref = $self->{$fname};
+       my $rr;
+       
+       if ($ref->{$ar} && exists $ref->{$ar}->{asc}) {
+               my $s = $ref->{$ar}->{asc};     # an optimisation?
+               $s =~ s/\$r/\$_[0]/g;
+#              $s =~ s/\\\\/\\/g;
+               $ref->{$ar}->{code} = eval "sub { $s }" ;
+               if ($@) {
+                       my $sort = $ref->{sort};
+                       my $name = $ref->{name};
+                       dbg("Error compiling $ar $sort $name: $@");
+                       Log('err', "Error compiling $ar $sort $name: $@");
+               }
+               $rr = $@;
+       }
+       return $rr;
+}
+
 sub read_in
 {
        my ($sort, $call, $flag) = @_;
@@ -85,41 +114,78 @@ sub read_in
        if ($fn = getfn($sort, $call, $flag)) {
                $in = undef; 
                my $s = readfilestr($fn);
-               my $newin = eval $s;
-               dbg('conn', "$@") if $@;
+               my $newin;
+               if ($s =~ /^\s*{/) {
+                       eval {$newin = $json->decode($s, __PACKAGE__)};
+               } else {        
+                       $newin = eval $s;
+               }
+               if ($@) {
+                       dbg($@);
+                       unlink($fn);
+                       return undef;
+               }
                if ($in) {
                        $newin = new('Filter::Old', $sort, $call, $flag);
                        $newin->{filter} = $in;
-               } else {
+               } elsif (ref $newin && $newin->can('getfilkeys')) {
                        my $filter;
                        my $key;
                        foreach $key ($newin->getfilkeys) {
-                               $filter = $newin->{$key};
-                               if ($filter->{reject} && exists $filter->{reject}->{asc}) {
-                                       $filter->{reject}->{code} = eval $filter->{reject}->{asc} ;
-                                       if ($@) {
-                                               my $sort = $newin->{sort};
-                                               my $name = $newin->{name};
-                                               dbg('err', "Error compiling reject $sort $key $name: $@");
-                                               Log('err', "Error compiling reject $sort $key $name: $@");
-                                       }
-                               }
-                               if ($filter->{accept} && exists $filter->{accept}->{asc}) {
-                                       $filter->{accept}->{code} = eval $filter->{accept}->{asc} ;
-                                       if ($@) {
-                                               my $sort = $newin->{sort};
-                                               my $name = $newin->{name};
-                                               dbg('err', "Error compiling accept $sort $key $name: $@");
-                                               Log('err', "Error compiling accept $sort $key $name: $@");
-                                       }
-                               } 
+                               $newin->compile($key, 'reject');
+                               $newin->compile($key, 'accept');
                        }
+               } else {
+                       # error on reading file, delete and exit
+                       dbg("empty or unreadable filter: $fn, deleted");
+                       unlink($fn);
+                       return undef;
                }
                return $newin;
        }
        return undef;
 }
 
+
+# this writes out the filter in a form suitable to be read in by 'read_in'
+# It expects a list of references to filter lines
+sub write
+{
+       my $self = shift;
+       my $sort = $self->{sort};
+       my $name = $self->{name};
+       my $dir = "$filterbasefn/$sort";
+       my $fn = "$dir/$name";
+
+       mkdir $dir, 0775 unless -e $dir; 
+    rename $fn, "$fn.o" if -e $fn;
+       my $fh = new IO::File ">$fn";
+       if ($fh) {
+#              my $dd = new Data::Dumper([ $self ]);
+#              $dd->Indent(1);
+#              $dd->Terse(1);
+#              $dd->Quotekeys($] < 5.005 ? 1 : 0);
+               #               $fh->print($dd->Dumpxs);
+
+               # remove code references, do the encode, then put them back again (they can't be represented anyway)
+               my $key;
+               foreach $key ($self->getfilkeys) {
+                       $self->{$key}->{reject}->{code} = undef if exists $self->{$key}->{reject};
+                       $self->{$key}->{accept}->{code} = undef if exists $self->{$key}->{accept};
+               }
+               $fh->print($json->encode($self));
+               foreach $key ($self->getfilkeys) {
+                       $self->compile($key, 'reject');
+                       $self->compile($key, 'accept');
+               }
+               $fh->close;
+       } else {
+               rename "$fn.o", $fn if -e "$fn.o";
+               return "$fn $!";
+       }
+       return undef;
+}
+
 sub getfilters
 {
        my $self = shift;
@@ -143,12 +209,15 @@ sub getfilkeys
 # The filter returns 0 if an entry is matched by any reject rule and also if any
 # accept rule fails otherwise it returns 1
 #
-# Either set of rules may be missing meaning an implicit 'ok'
+# Either set of rules may be missing meaning an implicit 'opposite' ie if it
+# a reject then ok else if an accept then not ok.
+#
+# you can set a default with either an accept/xxxx all or reject/xxxx all
 #
 # Unlike the old system, this is kept as a hash of hashes so that you can
 # easily change them by program.
 #
-# You can have a [any] number of 'filters', they are tried in random order until 
+# You can have 10 filter lines (0->9), they are tried in order until 
 # one matches
 #
 # There is a parser that takes a Filter::Cmd object which describes all the possible
@@ -177,79 +246,72 @@ sub it
 {
        my $self = shift;
        
-       my $hops = undef;
-       my $r = 1;
-               
        my $filter;
-       foreach $filter ($self->getfilters) {
-               $r = 0;
+       my @keys = sort $self->getfilkeys;
+       my $key;
+       my $type = 'Dunno';
+       my $asc = '?';
+
+       my $r = @keys > 0 ? 0 : 1;
+       foreach $key (@keys) {
+               $filter = $self->{$key};
                if ($filter->{reject} && exists $filter->{reject}->{code}) {
-                       next if &{$filter->{reject}->{code}}(\@_);                              
+                       $type = 'reject';
+                       $asc = $filter->{reject}->{user};
+                       if (&{$filter->{reject}->{code}}(ref $_[0] ? $_[0] : \@_)) {
+                               $r = 0;
+                               last;
+                       } else {
+                               $r = 1;
+                       }               
                }
                if ($filter->{accept} && exists $filter->{accept}->{code}) {
-                       next unless &{$filter->{accept}->{code}}(\@_);                          
+                       $type = 'accept';
+                       $asc = $filter->{accept}->{user};
+                       if (&{$filter->{accept}->{code}}(ref $_[0] ? $_[0] : \@_)) {
+                               $r = 1;
+                               last;
+                       } else {
+                               $r = 0;
+                       }                       
                } 
-               $r = 1;
-               last;
        }
 
-       # hops are done differently 
-       if ($self->{hops}) {
-               my ($comp, $ref);
-               while (($comp, $ref) = each %{$self->{hops}}) {
-                       my ($field, $h) = @$ref;
-                       if ($_[$field] =~ m{$comp}) {
-                               $hops = $h;
-                               last;
-                       } 
-               }               
-       }
-       return ($r, $hops);
-}
+       # hops are done differently (simply) 
+       my $hops = $self->{hops} if exists $self->{hops};
 
-# this writes out the filter in a form suitable to be read in by 'read_in'
-# It expects a list of references to filter lines
-sub write
-{
-       my $self = shift;
-       my $sort = $self->{sort};
-       my $name = $self->{name};
-       my $dir = "$filterbasefn/$sort";
-       my $fn = "$dir/$name";
+       if (isdbg('filter')) {
+               my $call = $self->{name};
+               my $args = join '\',\'', map {defined $_ ? $_ : 'undef'} (ref $_[0] ? @{$_[0]} : @_);
+               my $true = $r ? "OK " : "REJ";
+               my $sort = $self->{sort};
+               my $dir = $self->{name} =~ /^in_/i ? "IN " : "OUT";
 
-       mkdir $dir, 0775 unless -e $dir; 
-    rename $fn, "$fn.o" if -e $fn;
-       my $fh = new IO::File ">$fn";
-       if ($fh) {
-               my $dd = new Data::Dumper([ $self ]);
-               $dd->Indent(1);
-               $dd->Terse(1);
-               $dd->Quotekeys($] < 5.005 ? 1 : 0);
-               $fh->print($dd->Dumpxs);
-               $fh->close;
-       } else {
-               rename "$fn.o", $fn if -e "$fn.o";
-               return "$fn $!";
+               $call =~ s/\.PL$//i;
+               my $h = $hops || '';
+               dbg("Filter: $call $true $dir: $type/$sort with '$asc' on '$args' $h") if isdbg('filter');
        }
-       return undef;
+       return ($r, $hops);
 }
 
 sub print
 {
        my $self = shift;
+       my $name = shift || $self->{name};
+       my $sort = shift || $self->{sort};
+       my $flag = shift || "";
        my @out;
-       my $name = $self->{name};
        $name =~ s/.pl$//;
        
-       push @out, join(' ',  $name , ':', $self->{sort});
+       push @out, join(' ',  $name , ':', $sort, $flag);
        my $filter;
        my $key;
        foreach $key (sort $self->getfilkeys) {
                my $filter = $self->{$key};
-               if ($filter->{reject} && exists $filter->{reject}->{user}) {
+               if (exists $filter->{reject} && exists $filter->{reject}->{user}) {
                        push @out, ' ' . join(' ', $key, 'reject', $filter->{reject}->{user});
                }
-               if ($filter->{accept} && exists $filter->{accept}->{user}) {
+               if (exists $filter->{accept} && exists $filter->{accept}->{user}) {
                        push @out, ' ' . join(' ', $key, 'accept', $filter->{accept}->{user});
                } 
        }
@@ -262,14 +324,27 @@ sub install
        my $remove = shift;
        my $name = uc $self->{name};
        my $sort = $self->{sort};
-       my ($in) = $name =~ s/^IN_//;
+       my $in = "";
+       $in = "in" if $name =~ s/^IN_//;
        $name =~ s/.PL$//;
                
-       my $dxchan = DXChannel->get($name);
-       if ($dxchan) {
-               $in = lc $in if $in;
+       my $dxchan;
+       my @dxchan;
+       if ($name eq 'NODE_DEFAULT') {
+               @dxchan = DXChannel::get_all_nodes();
+       } elsif ($name eq 'USER_DEFAULT') {
+               @dxchan = DXChannel::get_all_users();
+       } else {
+               $dxchan = DXChannel::get($name);
+               push @dxchan, $dxchan if $dxchan;
+       }
+       foreach $dxchan (@dxchan) {
                my $n = "$in$sort" . "filter";
-               $dxchan->$n($remove ? undef : $self);
+               my $i = $in ? 'IN_' : '';
+               my $ref = $dxchan->$n();
+               if (!$ref || ($ref && uc $ref->{name} eq "$i$name.PL")) {
+                       $dxchan->$n($remove ? undef : $self);
+               }
        }
 }
 
@@ -301,6 +376,8 @@ sub delete
        }
 }
 
+
+
 package Filter::Cmd;
 
 use strict;
@@ -310,32 +387,56 @@ use DXDebug;
 use vars qw(@ISA);
 @ISA = qw(Filter);
 
+sub encode_regex
+{
+       my $s = shift;
+       $s =~ s/\{(.*?)\}/'{'. unpack('H*', $1) . '}'/eg if $s;
+       return $s;
+}
+
+sub decode_regex
+{
+       my $r = shift;
+       my ($v) = $r =~ /^\{(.*?)}$/;
+       return pack('H*', $v);
+}
+
+
 # the general purpose command processor
 # this is called as a subroutine not as a method
 sub parse
 {
-       my ($self, $dxchan, $line) = @_;
+       my ($self, $dxchan, $sort, $line, $forcenew) = @_;
        my $ntoken = 0;
        my $fno = 1;
        my $filter;
        my ($flag, $call);
        my $s;
-       my $user;
+       my $user = '';
        
        # check the line for non legal characters
-       return ('ill', $dxchan->msg('e19')) if $line =~ /[^\s\w,_\*\/\(\)]/;
+       dbg("Filter::parse line: '$line'") if isdbg('filter');
+       my @ch = $line =~ m|([^\s\w,_\.:\/\-\*\(\)\$!])|g;
+       return ('ill', $dxchan->msg('e19', join(' ', @ch))) if $line !~ /{.*}/ && @ch;
+
+       $line = lc $line;
+
+       # disguise regexes
+
+       dbg("Filter parse line after regex check: '$line'") if isdbg('filter');
+       $line = encode_regex($line);
        
        # add some spaces for ease of parsing
-       $line =~ s/([\(\)])/ $1 /g;
-       $line = lc $line;
+       $line =~ s/([\(\!\)])/ $1 /g;
        
        my @f = split /\s+/, $line;
-       my $conj = ' && ';
-       my $not = "";
+       dbg("filter parse: tokens '" . join("' '", @f) . "'") if isdbg('filter');
+       
+       my $lasttok = '';
        while (@f) {
                if ($ntoken == 0) {
                        
-                       if (@f && $dxchan->priv >= 8 && ((is_callsign(uc $f[0]) && DXUser->get(uc $f[0])) || $f[0] =~ /(?:node|user)_default/)) {
+                       if (!$forcenew &&  @f && $dxchan->priv >= 8 && ((is_callsign(uc $f[0]) && DXUser::get(uc $f[0])) || $f[0] =~ /(?:node|user)_default/)) {
                                $call = shift @f;
                                if ($f[0] eq 'input') {
                                        shift @f;
@@ -349,8 +450,8 @@ sub parse
                                $fno = shift @f;
                        }
 
-                       $filter = Filter::read_in('spots', $call, $flag);
-                       $filter = Filter->new('spots', $call, $flag) unless $filter;
+                       $filter = Filter::read_in($sort, $call, $flag) unless $forcenew;
+                       $filter = Filter->new($sort, $call, $flag) if !$filter || $filter->isa('Filter::Old');
                        
                        $ntoken++;
                        next;
@@ -359,49 +460,30 @@ sub parse
                # do the rest of the filter tokens
                if (@f) {
                        my $tok = shift @f;
-                       if ($tok eq '(') {
-                               if ($s) {
-                                       $s .= $conj;
-                                       $user .= $conj;
-                                       $conj = "";
-                               }
-                               if ($not) {
-                                       $s .= $not;
-                                       $user .= $not;
-                                       $not = "";
-                               }
-                               $s .= $tok;
-                               $user .= $tok;
-                               next;
-                       } elsif ($tok eq ')') {
-                               $conj = ' && ';
-                               $not ="";
-                               $s .= $tok;
+
+                       dbg("filter::parse: tok '$tok'") if isdbg('filter');
+                       
+                       if ($tok eq 'all') {
+                               $s .= '1';
                                $user .= $tok;
+                               last;
+                       } elsif (grep $tok eq $_, qw{and or not ( )}) {
+                               $s .= ' && ' if $tok eq 'and';
+                               $s .= ' || ' if $tok eq 'or';
+                               $s .= ' !' if $tok eq 'not';
+                               $s .=  $tok if $tok eq '(' or $tok eq ')';
+                               $user .= " $tok ";
                                next;
-                       } elsif ($tok eq 'or') {
-                               $conj = ' || ' if $conj ne ' || ';
-                               next;
-                       } elsif ($tok eq 'and') {
-                               $conj = ' && ' if $conj ne ' && ';
-                               next;
-                       } elsif ($tok eq 'not' || $tok eq '!') {
-                               $not = '!';
+                       } elsif ($tok eq '') {
                                next;
                        }
+                       
                        if (@f) {
                                my $val = shift @f;
                                my @val = split /,/, $val;
 
-                               if ($s) {
-                                       $s .= $conj ;
-                                       $s .= $not;
-                                       $user .= $conj;
-                                       $user .= $not;
-                                       $conj = ' && ';
-                                       $not = "";
-                               }
-                               $user .= "$tok $val";
+                               dbg("filter::parse: tok '$tok' val '$val'") if isdbg('filter');
+                               $user .= " $tok $val";
                                
                                my $fref;
                                my $found;
@@ -415,20 +497,31 @@ sub parse
                                                        }
                                                        @val = @nval;
                                                }
-                                               if ($fref->[1] eq 'a') {
+                                               if ($fref->[1] eq 'a' || $fref->[1] eq 't') {
                                                        my @t;
-                                                       for (@val) {
-                                                               s/\*//g;
-                                                               push @t, "\$r->[$fref->[2]]=~/$_/i";
+                                                       foreach my $v (@val) {
+                                                               $v =~ s/\*//g;        # remove any trailing *
+                                                               if (my ($r) = $v =~ /^\{(.*)\}$/) { # we have a regex
+                                                                       dbg("Filter::parse regex b: '\{$r\}'") if isdbg('filter'); 
+                                                                       $v = decode_regex($v);
+                                                                       dbg("Filter::parse regex a: '$v'") if isdbg('filter'); 
+                                                                       return  ('regex', $dxchan->msg('e38', $v)) unless (qr{$v});
+                                                                       push @t, "\$r->[$fref->[2]]=~m{$v}i";
+                                                                       $v = "{$r}"; # put it back together again for humans
+                                                               } else {
+                                                                       push @t, "\$r->[$fref->[2]]=~m{$v}i";
+                                                               }
                                                        }
                                                        $s .= "(" . join(' || ', @t) . ")";
+                                                       dbg("filter parse: s '$s'") if isdbg('filter');
                                                } elsif ($fref->[1] eq 'c') {
                                                        my @t;
                                                        for (@val) {
                                                                s/\*//g;
-                                                               push @t, "\$r->[$fref->[2]]=~/^\U$_/";
+                                                               push @t, "\$r->[$fref->[2]]=~m{^\U$_}";
                                                        }
                                                        $s .= "(" . join(' || ', @t) . ")";
+                                                       dbg("filter parse: s '$s'") if isdbg('filter');
                                                } elsif ($fref->[1] eq 'n') {
                                                        my @t;
                                                        for (@val) {
@@ -436,6 +529,19 @@ sub parse
                                                                push @t, "\$r->[$fref->[2]]==$_";
                                                        }
                                                        $s .= "(" . join(' || ', @t) . ")";
+                                                       dbg("filter parse: s '$s'") if isdbg('filter');
+                                               } elsif ($fref->[1] =~ /^n[ciz]$/ ) {    # for DXCC, ITU, CQ Zone    
+                                                       my $cmd = $fref->[1];
+                                                       my @pre = Prefix::to_ciz($cmd, @val);
+                                                       return ('numpre', $dxchan->msg('e27', $_)) unless @pre;
+                                                       $s .= "(" . join(' || ', map {"\$r->[$fref->[2]]==$_"} @pre) . ")";
+                                                       dbg("filter parse: s '$s'") if isdbg('filter');
+                                               } elsif ($fref->[1] =~ /^ns$/ ) {    # for DXCC, ITU, CQ Zone    
+                                                       my $cmd = $fref->[1];
+                                                       my @pre = Prefix::to_ciz($cmd, @val);
+                                                       return ('numpre', $dxchan->msg('e27', $_)) unless @pre;
+                                                       $s .= "(" . "!\$USDB::present || grep \$r->[$fref->[2]] eq \$_, qw(" . join(' ' ,map {uc} @pre) . "))";
+                                                       dbg("filter parse: s '$s'") if isdbg('filter');
                                                } elsif ($fref->[1] eq 'r') {
                                                        my @t;
                                                        for (@val) {
@@ -443,28 +549,73 @@ sub parse
                                                                push @t, "(\$r->[$fref->[2]]>=$1 && \$r->[$fref->[2]]<=$2)";
                                                        }
                                                        $s .= "(" . join(' || ', @t) . ")";
+                                                       dbg("filter parse: s '$s'") if isdbg('filter');
                                                } else {
-                                                       confess("invalid letter $fref->[1]");
+                                                       confess("invalid filter function $fref->[1]");
                                                }
                                                ++$found;
                                                last;
                                        }
                                }
-                               return ('unknown', $dxchan->msg('e20', $tok)) unless $found;
+                               return (1, $dxchan->msg('e20', $lasttok)) unless $found;
                        } else {
-                               return ('no', $dxchan->msg('filter2', $tok));
+                               $s = $tok =~ /^{.*}$/ ? '{' . decode_regex($tok) . '}' : $tok;
+                               return (1, $dxchan->msg('filter2', $s));
                        }
+                       $lasttok = $tok;
                }
-               
        }
 
-       # tidy up the user string
-       $user =~ s/\&\&/ and /g;
-       $user =~ s/\|\|/ or /g;
-       $user =~ s/\!/ not /g;
-       $user =~ s/\s+/ /g;
+       # tidy up the user string (why I have to stick in an if statement when I have initialised it I have no idea! 5.28 bug?
+       if ($user) {
+               $user =~ s/\)\s*\(/ and /g;
+               $user =~ s/\&\&/ and /g;
+               $user =~ s/\|\|/ or /g;
+               $user =~ s/\!/ not /g;
+               $user =~ s/\s+/ /g;
+               $user =~ s/\{(.*?)\}/'{'. pack('H*', $1) . '}'/eg;
+               $user =~ s/^\s+//;
+               dbg("filter parse: user '$user'") if isdbg('filter');
+       }
+
+       if ($s) {
+               $s =~ s/\)\s*\(/ && /g;
+               dbg("filter parse: s '$s'") if isdbg('filter');
+       }
+
        
-       return (0, $filter, $fno, $user, "sub { my \$r = shift; return $s }");
+       return (0, $filter, $fno, $user, $s);
+}
+
+# a filter accept/reject command
+sub cmd
+{
+       my ($self, $dxchan, $sort, $type, $line) = @_;
+       return $dxchan->msg('filter5') unless $line;
+
+       my ($r, $filter, $fno, $user, $s) = $self->parse($dxchan, $sort, $line);
+       return (1, $filter) if $r;
+       
+       my $u = DXUser::get_current($user);
+       return (1, $dxchan->msg('isow', $user)) if $u && $u->isolate;
+
+       my $fn = "filter$fno";
+
+       $filter->{$fn} = {} unless exists $filter->{$fn};
+       $filter->{$fn}->{$type} = {} unless exists $filter->{$fn}->{$type};
+
+       $filter->{$fn}->{$type}->{user} = $user;
+       $filter->{$fn}->{$type}->{asc} = $s;
+       $r = $filter->compile($fn, $type);   # NOTE: returns an ERROR, therefore 0 = success
+       return (0,$r) if $r;
+       
+       $r = $filter->write;
+       return (1,$r) if $r;
+
+       $filter->install(1);            # 'delete'
+       $filter->install;
+
+    return (0, $filter, $fno);
 }
 
 package Filter::Old;
@@ -492,8 +643,11 @@ use vars qw(@ISA);
 # to 'Filter::it' 
 #
 # The fieldsort is the type of field that we are dealing with which 
-# currently can be 'a', 'n', 'r' or 'd'. 'a' is alphanumeric, 'n' is 
-# numeric, 'r' is ranges of pairs of numeric values and 'd' is default.
+# currently can be 'a', 'n', 'r' or 'd'.
+#    'a' is alphanumeric
+#    'n' is# numeric
+#    'r' is ranges of pairs of numeric values
+#    'd' is default (effectively, don't filter)
 #
 # Filter::it basically goes thru the list of comparisons from top to
 # bottom and when one matches it will return the action and the action data as a list. 
@@ -532,13 +686,21 @@ sub it
                                return ($action, $actiondata)  if $val >= $range[$i] && $val <= $range[$i+1];
                        }
                } elsif ($fieldsort eq 'a') {
-                       return ($action, $actiondata)  if $_[$field] =~ m{$comp};
+                       return ($action, $actiondata)  if $_[$field] =~ m{$comp}i;
                } else {
-                       return ($action, $actiondata);      # the default action
+                       return ($action, $actiondata);      # the default action (just pass through)
                }
        }
 }
 
+sub print
+{
+       my $self = shift;
+       my $call = shift;
+       my $sort = shift;
+       my $flag = shift || "";
+       return "$call: Old Style Filter $flag $sort";
+}
 
 1;
 __END__