checklink: permit --exclude-docs to be supplied multiple times

This patch permits --exclude-docs to be supplied multiple times instead of
just once.

                    -Michael Ernst
cvs.bin diff: Diffing .
Index: checklink
===================================================================
RCS file: /sources/public/perl/modules/W3C/LinkChecker/bin/checklink,v
retrieving revision 4.118
diff -u -r4.118 checklink
--- checklink	17 Oct 2008 04:36:19 -0000	4.118
+++ checklink	20 Oct 2008 07:48:13 -0000
@@ -369,7 +369,7 @@
     Password          => undef,
     Base_Locations    => [],
     Exclude           => undef,
-    Exclude_Docs      => undef,
+    Exclude_Docs      => [],
     Masquerade        => 0,
     Masquerade_From   => '',
     Masquerade_To     => '',
@@ -401,10 +401,6 @@
   eval { $Opts{Exclude} = qr/$Opts{Exclude}/o; };
   &usage(1, "Error in exclude regexp: $@") if $@;
 }
-if (defined($Opts{Exclude_Docs})) {
-  eval { $Opts{Exclude_Docs} = qr/$Opts{Exclude_Docs}/o; };
-  &usage(1, "Error in exclude-docs regexp: $@") if $@;
-}
 if (defined($Opts{Trusted})) {
   eval { $Opts{Trusted} = qr/$Opts{Trusted}/io; };
   &usage(1, "Error in trusted domains regexp: $@") if $@;
@@ -616,7 +612,7 @@
                                           if $Opts{Depth} == 0; },
              'l|location=s'    => \@locs,
              'X|exclude=s',    => \$Opts{Exclude},
-             'exclude-docs=s', => \$Opts{Exclude_Docs},
+             'exclude-docs=s@', => \$Opts{Exclude_Docs},
              'u|user=s'        => \$Opts{User},
              'p|password=s'    => \$Opts{Password},
              't|timeout=i'     => \$Opts{Timeout},
@@ -1202,9 +1198,14 @@
 
   my $candidate = URI->new($uri)->canonical();
 
-  return 0
-      if ((defined($Opts{Exclude}) && $candidate =~ $Opts{Exclude}) ||
-          (defined($Opts{Exclude_Docs}) && $candidate =~ $Opts{Exclude_Docs}));
+  return 0 if (defined($Opts{Exclude}) && $candidate =~ $Opts{Exclude});
+  if (defined($Opts{Exclude_Docs})) {
+    for my $excluded_doc (@{$Opts{Exclude_Docs}}) {
+      if ($candidate =~ $excluded_doc) {
+        return 0;
+      }
+    }
+  }
 
   foreach my $base (@{$Opts{Base_Locations}}) {
     my $rel = $candidate->rel($base);
Index: checklink.pod
===================================================================
RCS file: /sources/public/perl/modules/W3C/LinkChecker/bin/checklink.pod,v
retrieving revision 1.19
diff -u -r1.19 checklink.pod
--- checklink.pod	10 Feb 2008 13:17:03 -0000	1.19
+++ checklink.pod	20 Oct 2008 07:48:13 -0000
@@ -78,6 +78,7 @@
 
 In recursive mode, do not check links in documents whose full, canonical
 URIs match I<regexp>.
+This option may be specified multiple times.
 
 =item B<-L, --languages> I<accept-language>
 

Received on Monday, 20 October 2008 07:52:10 UTC