"Fossies" - the Fresh Open Source Software Archive

Member "namefix.pl/libs/filter.pm" (13 Dec 2008, 1092 Bytes) of package /linux/privat/old/namefix.pl_4.0.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "filter.pm" see the Fossies "Dox" file reference documentation.

    1 #!/usr/bin/perl
    2 
    3 use strict;
    4 use warnings;
    5 
    6 # returns 1 if string matches current filter
    7 # currently in namefix gui filter is always on, it always returns a positive match
    8 # if the filter is blank
    9 
   10 sub match_filter
   11 {
   12     my $string = shift;
   13     my $filt = "";
   14 
   15     if($main::filter_string eq "")
   16     {
   17         return 1;
   18     }
   19 
   20     &plog(3, "sub match_filter: \"$string\"");
   21 
   22     if($string eq "")
   23     {
   24         &plog(0, "sub match_filter: ERROR: blank file passed");
   25         return 1;
   26     }
   27 
   28     if($string eq "..")
   29     {
   30         &plog(4, "sub match_filter: got .. passed");
   31         return 1;
   32     }
   33 
   34     $filt = $main::filter_string;
   35     if($main::disable_regexp == 1)
   36     {
   37         &plog(4, "sub match_filter: regexp disabled, using escaped string");
   38         $filt = $main::filter_string_escaped;
   39     }
   40 
   41     if
   42     (
   43         ($main::filter_cs == 1 && $string =~ /.*($filt).*/) ||
   44         ($main::filter_cs == 0 && $string =~ /.*($filt).*/i)
   45     ) 
   46     {
   47         &plog(4, "sub match_filter: string \"$string\" matched filter \"$filt\"");
   48         return 1;
   49     }
   50     &plog(4, "sub match_filter: string \"$string\" failed matched filter \"$filt\"");
   51         return 0;
   52 }
   53 
   54 1;