|
|
[Perlfect-search] indexer.pl
Jerrad Pierce perlfect-search@perlfect.com
Tue, 18 Feb 2003 22:02:08 -0500
sub load_excludes uses a bad regexp to check for comments.
I have some files which have # in the name that I wish to exclude
and cannot do so with the current regexp. Below is a patch to
improve the exclusion rule loader.
--- indexer.pl~ Tue Apr 9 03:22:54 2002
+++ indexer.pl Wed Feb 19 02:50:22 2003
@@ -579,17 +579,21 @@
sub load_excludes {
if (-e $NO_INDEX_FILE) {
open (FILE, $NO_INDEX_FILE) or (warn "Cannot open $NO_INDEX_FILE: $!" and next);
- while (<FILE>) {
- chomp;
- $_ =~ s/\r//g; # get rid of carriage returns
- $_ =~ s/(\#.*)//g; # ingore comments
+ while (chomp($_ = <FILE>)) {
+ next if /^\s*#/; # ignore comments
+ $_ =~ s/(?<!\\)(\#.*)//g;
+
+ my $readable = $_;
+
+ $_ =~ y/\r//d; # get rid of carriage returns
$_ =~ s/[\/\s]*$//; # remove any trailing spaces and slashes
- next if( ! $_ );
- print "\t- $_\n";
+ next unless $_;
$_ = quotemeta; # escape all non-alphanumeric characters
$_ =~ s/\\\*/\.\*/g; # except for the * which is replaced by .*
- push @no_index, $_;
+ $_ =~ s/\\\\\#/#/g; # and # which is a special case
+ push @no_index, qr/$_$/;
+ printf "\t%s =>\n\t\t%s\n", $readable, qr/$_$/;
}
close (FILE);
} else {
--
H4sICNoBwDoAA3NpZwA9jbsNwDAIRHumuC4NklvXTOD0KSJEnwU8fHz4Q8M9i3sGzkS7BBrm
OkCTwsycb4S3DloZuMIYeXpLFqw5LaMhXC2ymhreVXNWMw9YGuAYdfmAbwomoPSyFJuFn2x8
Opr8bBBidccAAAA=
--
MOTD on Prickle-Prickle, the 49th of Chaos, in the YOLD 3169:
This statement is false.
|
|