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

[SCM] Debian package checker branch, master, updated. 1.24.3-23-gb28190b



The following commit has been merged in the master branch:
commit e35453e390366ad5bf7bef8bbaaa44fe2b3b543e
Author: Jordà Polo <jorda@ettin.org>
Date:   Wed Aug 6 21:56:05 2008 +0200

    Implement support for new manual references
    
    This change not only makes it possible to display titles in addition to
    chapters/sections, but it also allows IDs in references (e.g. Ref: fhs
    usrsharemanmanualpages).

diff --git a/lib/Manual_refs.pm b/lib/Manual_refs.pm
index 2e19012..111a8e7 100644
--- a/lib/Manual_refs.pm
+++ b/lib/Manual_refs.pm
@@ -18,15 +18,7 @@
 
 use strict;
 
-# define hash for manuals
-my %manual =
-(
- 'policy' => 'Policy Manual',
- 'devref' => 'Developers Reference',
- 'fhs'    => 'FHS',
-);
-
-my %url;
+our %refs;
 
 my $lib = defined $ENV{LINTIAN_ROOT} ?  "$ENV{LINTIAN_ROOT}/" : "";
 
@@ -35,12 +27,16 @@ open (REFS, '<', "${lib}lib/manual_refs")
 
 while(<REFS>) {
     chomp;
-    next if m/^\s*\#/;
+    next if not m/^(.+?)::(.*?)::(.+?)::(.+?)$/;
 
-    my ($key, $data) = split;
-    $url{$key} = $data;
+    my ($man, $section, $title, $u) = split('::');
+    $section = '0' if $section eq "";
+    $refs{$man}{$section}{title} = $title;
+    $refs{$man}{$section}{url} = $u;
 }
 
 close REFS;
 
 1;
+
+# vim: sw=4 sts=4 ts=4 et sr
diff --git a/lib/Read_taginfo.pm b/lib/Read_taginfo.pm
index 70fff22..93317a1 100644
--- a/lib/Read_taginfo.pm
+++ b/lib/Read_taginfo.pm
@@ -26,19 +26,13 @@ use lib "$ENV{'LINTIAN_ROOT'}/lib";
 use Util;
 use Text_utils;
 use Manual_refs;
-use vars qw(%url); # from the above
 
 use strict;
 
-# define hash for manuals
-my %manual = (
-	      'policy' => 'Policy Manual',
-	      'devref' => 'Developers Reference',
-	      'fhs' => 'FHS',
-	     );
-
 srand;
 
+our %refs; # from Manual_refs
+
 # load information about checker scripts
 sub read_tag_info {
     my ($type) = @_;
@@ -83,42 +77,59 @@ sub read_tag_info {
     return \%tag_info;
 }
 
-sub format_ref {
-    my ($ref) = @_;
+sub manual_ref {
+    my ($man, $sub) = @_;
+    my $numbered = ($sub =~ /[A-Z\d\.]+/) ? 1 : 0;
+    my $chapter = ($sub =~ /^[\d]+$/) ? 1 : 0;
+    my $appendix = ($sub =~ /^[A-Z]+$/) ? 1 : 0;
 
-    my @foo = split(/\s*,\s*/o,$ref);
-    my $u;
-    for ($u=0; $u<=$#foo; $u++) {
-	if ($foo[$u] =~ m,^\s*(policy|devref|fhs)\s*([\d\.]+)?\s*$,oi) {
-	    my ($man,$sec) = ($1,$2);
+    return "" if not exists $refs{$man}{0};
 
-	    $foo[$u] = $manual{lc $man};
+    my $man_title = $refs{$man}{0}{title};
+    my $man_url = $refs{$man}{0}{url};
+    my $text = "<a href='$man_url'>$man_title</a>";
 
-	    if ($sec =~ m,^\d+$,o) {
-		$foo[$u] .= ", chapter $sec";
-	    } elsif ($sec) {
-		$foo[$u] .= ", section $sec";
-	    }
+    my $div = '';
+    $div = "section $sub " if $numbered;
+    $div = "chapter $sub " if $chapter;
+    $div = "appendix $sub " if $appendix;
 
-	    if (exists $url{"$man-$sec"}) {
-		$foo[$u] = "<a href=\"$url{\"$man-$sec\"}\">$foo[$u]</a>";
-	    } elsif (exists $url{$man}) {
-		$foo[$u] = "<a href=\"$url{$man}\">$foo[$u]</a>";
-	    }
-	} elsif ($foo[$u] =~ m,^\s*((?:ftp|https?)://[\S~-]+?/?)\s*$,i) {
-	    $foo[$u] = "<a href=\"$1\">$1</a>";
-	} elsif ($foo[$u] =~ m,\s*([\w_-]+\(\d+\w*\))\s*$,i) {
-	    $foo[$u] = "the $foo[$u] manual page";
-	}
+    if (exists $refs{$man}{$sub}) {
+        my $sub_title = $refs{$man}{$sub}{title};
+        my $sub_url = $refs{$man}{$sub}{url};
+        $text .= " $div(<a href='$sub_url'>$sub_title</a>)";
     }
-	
-    if ($#foo+1 > 2) {
-	$ref = sprintf "Refer to %s, and %s for details.",join(', ',splice(@foo,0,$#foo)),@foo;
-    } elsif ($#foo+1 > 0) {
-	$ref = sprintf "Refer to %s for details.",join(' and ',@foo);
+
+    return $text;
+}
+
+sub format_ref {
+    my ($header) = @_;
+    my $text = '';
+    my @list;
+
+    foreach my $ref (split(/,\s?/, $header)) {
+        if ($ref =~ /^([\w-]+)\s(.+)$/) {
+            $text = manual_ref($1, $2);
+        } elsif ($ref =~ /^[\w_-]+\(\d\)$/) {
+            $text = "the $ref manual page";
+        } elsif ($ref =~ /^(?:ftp|https?):\/\//) {
+            $text = "<a href='$ref'>$ref</a>";
+        }
+        push(@list, $text) if $text;
     }
 
-    return $ref;
+    if ($#list >= 2) {
+        $text = join(', ', splice(@list , 0, $#list));
+        $text = "Refer to $text, and @list for details.";
+    } elsif ($#list >= 0) {
+        $text = join(' and ', @list);
+        $text = "Refer to $text for details.";
+    }
+
+    return $text;
 }
 
 1;
+
+# vim: sw=4 sts=4 ts=4 et sr

-- 
Debian package checker


Reply to: