Author: jeroen
Date: 2004-05-02 01:15:58 +0200 (Sun, 02 May 2004)
New Revision: 244

Added:
   trunk/lib/Tags.pm
Modified:
   trunk/frontend/lintian
   trunk/private/TODO
Log:
Added lib/Tags, for generic tag outputting


Modified: trunk/frontend/lintian
===================================================================
--- trunk/frontend/lintian      2004-05-01 20:17:57 UTC (rev 243)
+++ trunk/frontend/lintian      2004-05-01 23:15:58 UTC (rev 244)
@@ -76,11 +76,9 @@
 
 my %collection_info;
 my %already_scheduled;
-my %overridden;
 my %checks;
 my %check_abbrev;
 my %unpack_infos;
-our %experimental_tag;
 my %check_info;
 
 # reset configuration variables
@@ -860,6 +858,8 @@
 
 closedir(COLLDIR);
 
+require Tags;
+import Tags;
 
 # load information about checker scripts
 opendir(CHECKDIR, "$LINTIAN_ROOT/checks")
@@ -876,60 +876,57 @@
 
     # ignore check `lintian' (this check is a special case and contains the
     # tag info for the lintian frontend--this script here)
-    next if $secs[0]->{'check-script'} eq 'lintian';
+    if ($secs[0]->{'check-script'} ne 'lintian') {
 
-    delete $secs[0]->{'check-script'};
-    $check_info{$script}->{'script'} = $script;
-    my $p = $check_info{$script};
+       delete $secs[0]->{'check-script'};
+       $check_info{$script}->{'script'} = $script;
+       my $p = $check_info{$script};
 
-    set_value($f,$p,'type',$secs[0],1);
-    # convert Type:
-    my ($b,$s,$u) = ( "", "", "" );
-    for (split(/\s*,\s*/o,$p->{'type'})) {
-       if ($_ eq 'binary') {
-           $b = 'b';
-       } elsif ($_ eq 'source') {
-           $s = 's';
-       } elsif ($_ eq 'udeb') {
-           $u = 'u';
-       } else {
-           fail("unknown type $_ specified in description file $f");
+       set_value($f,$p,'type',$secs[0],1);
+       # convert Type:
+       my ($b,$s,$u) = ( "", "", "" );
+       for (split(/\s*,\s*/o,$p->{'type'})) {
+           if ($_ eq 'binary') {
+               $b = 'b';
+           } elsif ($_ eq 'source') {
+               $s = 's';
+           } elsif ($_ eq 'udeb') {
+               $u = 'u';
+           } else {
+               fail("unknown type $_ specified in description file $f");
+           }
        }
-    }
-    $p->{'type'} = "$s$b$u";
+       $p->{'type'} = "$s$b$u";
 
-    set_value($f,$p,'unpack-level',$secs[0],1);
-    set_value($f,$p,'abbrev',$secs[0],1);
+       set_value($f,$p,'unpack-level',$secs[0],1);
+       set_value($f,$p,'abbrev',$secs[0],1);
 
-    if (exists $secs[0]->{'needs-info'} && defined $secs[0]->{'needs-info'}) {
-       for (split(/\s*,\s*/o,$secs[0]->{'needs-info'})) {
-           $p->{$_} = 1;
+       if (exists $secs[0]->{'needs-info'} && defined 
$secs[0]->{'needs-info'}) {
+           for (split(/\s*,\s*/o,$secs[0]->{'needs-info'})) {
+               $p->{$_} = 1;
+           }
+           delete $secs[0]->{'needs-info'};
        }
-       delete $secs[0]->{'needs-info'};
-    }
 
-    # ignore Info: and other fields for now...
-    delete $secs[0]->{'info'};
-    delete $secs[0]->{'standards-version'};
-    delete $secs[0]->{'author'};
+       # ignore Info: and other fields for now...
+       delete $secs[0]->{'info'};
+       delete $secs[0]->{'standards-version'};
+       delete $secs[0]->{'author'};
 
-    for (keys %{$secs[0]}) {
-       print STDERR "warning: unused tag $_ in description file $f\n";
-    }
+       for (keys %{$secs[0]}) {
+           print STDERR "warning: unused tag $_ in description file $f\n";
+       }
 
-    if ($debug >= 2) {
-       for (sort keys %$p) {
-           print "N:  $_: $p->{$_}\n";
+       if ($debug >= 2) {
+           for (sort keys %$p) {
+               print "N:  $_: $p->{$_}\n";
+           }
        }
-    }
 
+    } # end: if ne lintian
+
     shift(@secs);
-    for my $taginf (@secs) {
-       if (exists $taginf->{'experimental'} 
-           and $taginf->{'experimental'} =~ m/yes/i) {
-           $experimental_tag{$taginf->{'tag'}} = 1;
-       }
-    }
+    map Tags::add_tag($_), @secs;
 }
 
 closedir(CHECKDIR);

Added: trunk/lib/Tags.pm
===================================================================
--- trunk/lib/Tags.pm   2004-05-01 20:17:57 UTC (rev 243)
+++ trunk/lib/Tags.pm   2004-05-01 23:15:58 UTC (rev 244)
@@ -0,0 +1,68 @@
+# Tags -- Perl tags functions for lintian
+# $Id$
+
+# Copyright (C) 1998-2004 Various authors
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, you can find it on the World Wide
+# Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
+# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+# MA 02111-1307, USA.
+
+package Tags;
+use strict;
+
+use Exporter 'import';
+our @EXPORT = qw(tag);
+
+my $LINTIAN_ROOT = $::LINTIAN_ROOT;
+
+# Can also be more precise later on (only verbose with lab actions) but for
+# now this will do --Jeroen
+my $verbose = $::verbose;
+my $debug = $::debug;
+
+# What to print between the "E:" and the tag, f.e. "package source"
+my $prefix = undef;
+
+# The master hash with all tag info. Key is a hash too, with these stuff:
+# - tag: short name
+# - type: error/warning/info/experimental
+# - info: Description in HTML
+# - ref: Any references
+# - experimental: experimental status (possibly undef)
+my %tags;
+
+my $codes = { 'error' => 'E' , 'warning' => 'W' , 'info' => 'I' };
+
+# Call this function to add a certain tag, by supplying the info as a hash
+sub add_tag {
+       my $newtag = shift;
+       fail("Duplicate tag: $newtag->{'tag'}")
+               if exists $tags{$newtag->{'tag'}};
+       
+       $tags{$newtag->{'tag'}} = $newtag;
+}
+
+sub tag {
+       my $tag = shift;
+       my $info = $tags{$tag};
+       my $extra = '';
+       $extra = ' '.join(' ', map { s,\n,\\n, } @_) if $#_ >=0;
+
+       print "$codes->{$info->{'type'}}: $prefix: $tag$extra\n";
+}
+
+1;
+
+# vim: ts=4 sw=4 noet


Property changes on: trunk/lib/Tags.pm
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: trunk/private/TODO
===================================================================
--- trunk/private/TODO  2004-05-01 20:17:57 UTC (rev 243)
+++ trunk/private/TODO  2004-05-01 23:15:58 UTC (rev 244)
@@ -34,6 +34,7 @@
 - go through all checks and try to move common code to modules
 - go through the test suite and organise it more cleanly
 - update doc/CREDITS file
+- Fix experimental support back in
 
 old todo list
 =============

Reply via email to