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

[lintian] 05/07: private/refresh-manual-refs: Don't trump earlier refs on section reuse



This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository lintian.

commit 4a575321915a96298843ddbe00a56bd8d0db977a
Author: Ville Skyttä <ville.skytta@iki.fi>
Date:   Sat Oct 14 11:35:12 2017 +0300

    private/refresh-manual-refs: Don't trump earlier refs on section reuse
    
    Some manuals reuse section numbers for different references, e.g. the
    Debian Policy's normal and appendix sections are numbers that clash with
    each other as of 4.1.1.1 (and seems that is not easily fixable in it).
    Track if we've already seen a section pointing to some other URL than
    the current one, and uniquify it by appending as many asterisks as
    necessary.
    
    Signed-off-by: Chris Lamb <lamby@debian.org>
---
 private/refresh-manual-refs | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/private/refresh-manual-refs b/private/refresh-manual-refs
index 3d89822..f0784cd 100755
--- a/private/refresh-manual-refs
+++ b/private/refresh-manual-refs
@@ -185,6 +185,8 @@ sub extract_refs {
     # the Developer's Reference are cut in the middle of <a>...</a>.
     local $/ = "\n\n";
 
+    my %seen_sections;
+
     while (<$page_fd>) {
         if (not $title and m/$title_re/) {
             $title = 1;
@@ -211,13 +213,24 @@ sub extract_refs {
                 $ref{url} = basename($page) . "#$ref{url}";
             }
 
-            $ref{section} =~ s/^\#(.+)$/\L$1/;
             $ref{title} =~ s/\s+/ /g;
             $ref{title} =~ s,<span[^>]*>(.*?)</span ?>,$1,ig;
             $ref{title} =~ s,<code[^>]*>(.*?)</code ?>,<code>$1</code>,ig;
+
             $ref{url} = "$url$ref{url}";
             $ref{url} = '' if not $url;
 
+            $ref{section} =~ s/^\#(.+)$/\L$1/;
+            # Some manuals reuse section numbers for different references,
+            # e.g. the Debian Policy's normal and appendix sections are
+            # numbers that clash with each other. Track if we've already
+            # seen a section pointing to some other URL than the current one,
+            # and uniquify it by appending as many asterisks as necessary.
+            $ref{section} .= '*'
+              while (defined($seen_sections{$ref{section}})
+                && $seen_sections{$ref{section}} ne $ref{url});
+            $seen_sections{$ref{section}} = $ref{url};
+
             my @out = ($manual, $ref{section}, $ref{title}, $ref{url});
             print {$fh} join('::', @out) . "\n";
         }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: