Allows to add an asterisk at the start and/or end of the additional info to match arbitrary strings. This ensures nearly full backwards compatibility and should cover many cases where you might want to use this new feature. --- debian/changelog | 7 +++++++ doc/lintian.sgml | 11 +++++++---- frontend/lintian | 13 ++++++++----- lib/Tags.pm | 43 ++++++++++++++++++++++++++++++------------- 4 files changed, 52 insertions(+), 22 deletions(-)
Comments welcome. diff --git a/debian/changelog b/debian/changelog index dd667ef..1940b02 100644 --- a/debian/changelog +++ b/debian/changelog @@ -51,6 +51,9 @@ lintian (2.0.0~rc1) experimental; urgency=low variable assignment as well and reduce false positives by ignoring uses with $RANDOM or without a filename. Based on a patch from Raphael Geissert. + + * doc/lintian.sgml: + + [FL] Document wildcard support in overrides. * frontend/lintian: + [RA] Ensure we close the pipe to lintian-info before exiting, since @@ -58,6 +61,10 @@ lintian (2.0.0~rc1) experimental; urgency=low lintian exits, producing confusing output interleaved with the shell prompt. (Closes: #496295) + * lib/Tags.pm: + + [FL] Add support for specifying wildcards in overrides. + (Closes: #253884) + * lib/Tags/ColonSeparated.pm: + [FL] Update for new features and make a little bit easier to read for humans: diff --git a/doc/lintian.sgml b/doc/lintian.sgml index 6b8953b..1442aff 100644 --- a/doc/lintian.sgml +++ b/doc/lintian.sgml @@ -8,7 +8,7 @@ <author>Sean 'Shaleh' Perry <email>[EMAIL PROTECTED]</email> <author>Frank Lichtenheld <email>[EMAIL PROTECTED]</email> <author>Contact address: <email>[EMAIL PROTECTED]</email> -<version>version 1.23.8, 31 January 2005 +<version>version 2.0.0, 02 September 2008 <abstract> This manual describes Lintian, the Debian package checker. @@ -16,7 +16,7 @@ This manual describes Lintian, the Debian package checker. <copyright>Copyright © 1998 Christian Schwarz and Richard Braakman Copyright © 2000 Sean 'Shaleh' Perry - Copyright © 2004 Frank Lichtenheld + Copyright © 2004,2008 Frank Lichtenheld <p> This manual is free software; you may redistribute it and/or @@ -456,7 +456,7 @@ not used in current Lintian versions. The format of the overrides file is simple, it consists of one override per line (and may contain empty lines and comments, starting with a #, on others): <tt>[<package>[ <type>]: ]<lintian-tag>[ -<lintian-info>]</tt>. <tt><package></tt> is the package name; +[*]<lintian-info>[*]]</tt>. <tt><package></tt> is the package name; <tt><type></tt> is one of <tt>binary</tt>, <tt>udeb</tt> and <tt>source</tt>, and <tt><lintian-info></tt> is all additional information provided by Lintian except for the tag. What's inside brackets is @@ -489,7 +489,10 @@ Many tags can occour more than once (e.g. if the same error is found in more than one file). You can override a tag either completly 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). +in the examples). If you add an asterisk (<tt>*</tt>) 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. <chapt>Advanced usage diff --git a/frontend/lintian b/frontend/lintian index 964c3a4..c4ff4f8 100755 --- a/frontend/lintian +++ b/frontend/lintian @@ -1454,10 +1454,11 @@ for (reverse sort @packages) { s/\s+/ /go; my $override = $_; $override =~ s/^\Q$pkg\E( \Q$long_type\E)?: //; - if ($override eq '' or $override !~ /^[\w0-9.+-]+(\s+.*)?$/) { + if ($override eq '' or $override !~ /^[\w.+-]+(\s.*)?$/) { tag ('malformed-override', $_); } else { - Tags::add_override($override); + my ($tag, $extra) = split(/ /, $override, 2); + Tags::add_override($tag, $extra); } } close(O); @@ -1512,10 +1513,12 @@ for (reverse sort @packages) { if (not $no_override) { my $overrides = Tags::get_overrides( $file ); - for my $o (sort keys %$overrides) { - next if $overrides->{$o}; + for my $tag (sort keys %$overrides) { + for my $extra (sort keys %{$overrides->{$tag}}) { + next if $overrides->{$tag}{$extra}; - tag( "unused-override", $o ); + tag( "unused-override", $tag, $extra ); + } } } diff --git a/lib/Tags.pm b/lib/Tags.pm index 43f7e92..452e3ee 100644 --- a/lib/Tags.pm +++ b/lib/Tags.pm @@ -171,19 +171,20 @@ sub reset { # Add an override. If you specifiy two arguments, the first will be taken # as file to add the override to, otherwise 'current' will be assumed sub add_override { - my ($tag, $file) = ( "", "" ); - if (@_ > 1) { - ($file, $tag) = @_; + my ($tag, $extra, $file) = ( "", "", "" ); + if (@_ > 2) { + ($file, $tag, $extra) = @_; } else { - ($file, $tag) = ($current, @_); + ($file, $tag, $extra) = ($current, @_); } + $extra ||= ""; unless ($file) { warn "Don't know which package to add override $tag to"; return 0; } - $info{$file}{overrides}{$tag} = 0; + $info{$file}{overrides}{$tag}{$extra} = 0; return 1; } @@ -218,14 +219,30 @@ sub check_overrides { my ( $tag_info, $information ) = @_; my $extra = ''; - $extra = " @$information" if @$information; - $extra = '' if $extra eq ' '; - if( exists $info{$current}{overrides}{$tag_info->{tag}}) { - $info{$current}{overrides}{$tag_info->{tag}}++; - return $tag_info->{tag}; - } elsif( exists $info{$current}{overrides}{"$tag_info->{tag}$extra"} ) { - $info{$current}{overrides}{"$tag_info->{tag}$extra"}++; - return "$tag_info->{tag}$extra"; + $extra = "@$information" if @$information; + my $tag = $tag_info->{tag}; + my $overrides = $info{$current}{overrides}{$tag}; + return unless $overrides; + + if( exists $overrides->{''} ) { + $overrides->{''}++; + return $tag; + } elsif( $extra and exists $overrides->{$extra} ) { + $overrides->{$extra}++; + return "$tag $extra"; + } elsif ( $extra ) { + foreach (keys %$overrides) { + my $regex = $_; + if (m/^\*/ or m/\*$/) { + my ($start, $end) = ("",""); + $start = '.*' if $regex =~ s/^\*//; + $end = '.*' if $regex =~ s/\*$//; + if ($extra =~ /^$start\Q$regex\E$end$/) { + $overrides->{$_}++; + return "$tag $_"; + } + } + } } return ''; -- 1.5.6.5 Gruesse, -- Frank Lichtenheld <[EMAIL PROTECTED]> www: http://www.djpig.de/ -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]