[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#617991: Bug#622888: lintian overrides should support more precise pattern matching



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 2011-04-25 18:17, Niels Thykier wrote:
> Hi
> 
> I have looked a bit on this and ...
> 
>  * Allowing "*" anywhere in the extra will help a lot but is not enough.
>    - some tags might only be emitted on certain architectures and will
>      therefore cause unused-override on all other architectures
>    - See #622888

     - I have attached a patch for this. :)  Please review/test/comment
       on it.  I intend to apply it this weekend unless you believe
       there are any issues (with the patch or my proposed solution)

~Niels

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBCAAGBQJNuHDoAAoJEAVLu599gGRCvDYP/RA2cT/h64PfYbVDwCYXlMuj
s6Aunspsll3Ux0GXzZvy89dlnUo9J2PVP8HaJA4xck1r+ZnUM3piZzFuWqBzC4/p
s3edJx/tFLAO5QHj9UPGa2qZ63pIIPdT8VPeEgmy7XjFfk+CpGz8hHgB4L3O1tbj
xmHPB09Up0PqAKJMRTJGFDdoY+Ob1dPapfH2niYZt8+NiJXwuxLO96rgO8o183UI
B2yzUcihvwuR2NeEeOeQnlt0kHdhegpjXUxAJ6xBd/hqzuB18LlMNuijkVGy0pLp
JjW59RUQ0yDH8k3Zo0pcB9VQ+Qru0eSQyJ3t0G5mZXBi6MDRiuhy+vHkzSrD5iJ+
Vm9OkX9dLutj2KaVrVKfAttX/60RDCxPllhG2TxRYAB97iLsPSCgdnON11jZwuPl
n0bSGgVaXq7Ejcq4WePrshYFC3J2Un22lDTSEmdTIXnmqrLuJYyA8wHGZfck97gA
kTSye/eslBUvxR6As4PjVaSE8TUXkD6Ts79ceVEXj69nIN0bAci0rjwMUxJY2/Zt
DTlaSrKBSzLXiyyoW3+GZLaZJc3g+fkR7wAh9vqR2NYpb6UMHZeAYYwfnV44MHFo
ppGj5P+BuuTyKS9ehzNzzIciTJn9wIphgsTO0pkKKiHrrTJERSVf0PNUqgDg8DVM
6p7x/yvmYUSYasyrflKk
=zQx2
-----END PGP SIGNATURE-----
>From 40942ec56941b93850906c143f218b386560e15e Mon Sep 17 00:00:00 2001
From: Niels Thykier <niels@thykier.net>
Date: Wed, 27 Apr 2011 21:29:23 +0200
Subject: [PATCH] Allow override wildcards any where in the additional info part

Previously we only allowed it in the begining or/and in the end.
---
 debian/changelog                                   |    3 ++
 debian/copyright                                   |    2 +-
 doc/lintian.xml                                    |   13 +++++++----
 lib/Lintian/Tags.pm                                |   23 +++++++++++++++----
 .../debian/debian/overrides.lintian-overrides      |    1 -
 t/tests/overrides/tags                             |    4 +--
 6 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 79707b8..68d02f3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -25,6 +25,9 @@ lintian (2.5.0~rc4) UNRELEASED; urgency=low
     + [NT] Properly handle if the changes file is located directly in the
       file system root.  Thanks to Trent W. Buck for the bug report.
       (Closes: #624149)
+  * lib/Lintian/Tags.pm:
+    + [NT] Allow overrides to use wildcards anywhere instead of only in
+      the beginning or the end.  (Closes: #617991)
 
  -- Adam D. Barratt <adam@adam-barratt.org.uk>  Sat, 23 Apr 2011 13:37:52 +0100
 
diff --git a/debian/copyright b/debian/copyright
index f5fb30d..8463f43 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -46,7 +46,7 @@ Portions Copyright (C) 2008-2010 Raphael Geissert
 Portions Copyright (C) 2008-2010 Adam D. Barratt
 Portions Copyright (C) 2009 Stéphane Glondu
 Portions Copyright (C) 2010 Raphaël Hertzog
-Portions Copyright (C) 2010 Niels Thykier
+Portions Copyright (C) 2010-2011 Niels Thykier
 Portions Copyright (C) 2011 Gerfried Fuchs
 
 This program is free software; you may redistribute it and/or modify
diff --git a/doc/lintian.xml b/doc/lintian.xml
index feb27d7..150c19e 100644
--- a/doc/lintian.xml
+++ b/doc/lintian.xml
@@ -528,11 +528,14 @@ foo source: configure-generated-file-in-source config.cache
         completely by specifying its name (first line in the examples)
         or only one occurrence of it by specifying the additional
         info, too (second line in the examples).  If you add an
-        asterisk (<literal>*</literal>) at the start and/or end of the
-        additional info, this will match arbitrary strings similar to
-        the shell wildcard.  Asterisks located at any other place in
-        the info have no special meaning.  This wildcard support was
-        added in Lintian version 2.0.0.
+        asterisk (<literal>*</literal>) in the additional info, this
+        will match arbitrary strings similar to the shell wildcard.
+      </para>
+      <para>
+        The first wildcard support appeared in Lintian 2.0.0, which
+        only allowed the wildcards in the very beginning or end.
+        Version 2.5.0~rc4 extended this to allow wildcards any where
+        in the additional info.
       </para>
     </sect1>
   </chapter>
diff --git a/lib/Lintian/Tags.pm b/lib/Lintian/Tags.pm
index 7f6b4cf..8d570a8 100644
--- a/lib/Lintian/Tags.pm
+++ b/lib/Lintian/Tags.pm
@@ -201,11 +201,24 @@ sub _check_overrides {
     } elsif ($extra ne '') {
         for (sort keys %$overrides) {
             my $pattern = $_;
-            next unless ($pattern =~ /^\*/ or $pattern =~ /\*\z/);
-            my ($start, $end) = ('', '');
-            $start = '.*' if $pattern =~ s/^\*//;
-            $end   = '.*' if $pattern =~ s/\*$//;
-            if ($extra =~ /^$start\Q$pattern\E$end\z/) {
+            my $end = '';
+            my $pat = '';
+            next unless $pattern =~ m/\Q*\E/o;
+            # Split does not help us if $text ends with *
+            # so we deal with that now
+            if ($pattern =~ s/\Q*\E+\z//o){
+                $end = '.*';
+            }
+            # Are there any * left (after the above)?
+            if ($pattern =~ m/\Q*\E/o) {
+                # this works even if $text starts with a *, since
+                # that is split as '', <text>
+                my @pargs = split(m/\Q*\E++/o, $pattern);
+                $pat = join('.*', map { quotemeta($_) } @pargs);
+            } else {
+                $pat = $pattern;
+            }
+            if ($extra =~ m/^$pat$end\z/) {
                 $overrides->{$_}++;
                 return "$tag $_";
             }
diff --git a/t/tests/overrides/debian/debian/overrides.lintian-overrides b/t/tests/overrides/debian/debian/overrides.lintian-overrides
index 16ac4da..23f3eb5 100644
--- a/t/tests/overrides/debian/debian/overrides.lintian-overrides
+++ b/t/tests/overrides/debian/debian/overrides.lintian-overrides
@@ -6,5 +6,4 @@ hyphen-used-as-minus-sign usr/share/man/man1/foo.1.gz:4
 hyphen-used-as-minus-sign usr/share/man/man1/foo.1.gz:2*
 hyphen-used-as-minus-sign */foo.1.gz:5
 hyphen-used-as-minus-sign */foo.1.gz:3*
-# misused wildcard
 hyphen-used-as-minus-sign usr/share/man/man1/foo.1.gz * more occurrences not shown
diff --git a/t/tests/overrides/tags b/t/tests/overrides/tags
index bf32a7d..01a576c 100644
--- a/t/tests/overrides/tags
+++ b/t/tests/overrides/tags
@@ -1,7 +1,5 @@
-I: overrides: hyphen-used-as-minus-sign usr/share/man/man1/foo.1.gz 2 more occurrences not shown
 I: overrides: hyphen-used-as-minus-sign usr/share/man/man1/foo.1.gz:12
 I: overrides: hyphen-used-as-minus-sign usr/share/man/man1/foo.1.gz:13
 I: overrides: hyphen-used-as-minus-sign usr/share/man/man1/foo.1.gz:14
 I: overrides: hyphen-used-as-minus-sign usr/share/man/man1/foo.1.gz:6
-I: overrides: unused-override hyphen-used-as-minus-sign usr/share/man/man1/foo.1.gz * more occurrences not shown
-N: 7 tags overridden (1 warning, 6 info)
+N: 8 tags overridden (1 warning, 7 info)
-- 
1.7.4.1

Attachment: 0001-Allow-override-wildcards-any-where-in-the-additional.patch.sig
Description: Binary data


Reply to: