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

[SCM] Debian package checker branch, master, updated. 2.5.6-92-g2aeb44e



The following commit has been merged in the master branch:
commit 2aeb44e506a2ccf1c7150ba4f14f630394f1295f
Author: Niels Thykier <niels@thykier.net>
Date:   Fri Apr 13 00:00:09 2012 +0200

    c/changelog-file: Output the correct line number for "line-too-long"
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/checks/changelog-file b/checks/changelog-file
index 06f2181..514dd48 100644
--- a/checks/changelog-file
+++ b/checks/changelog-file
@@ -266,6 +266,11 @@ if (my @errors = $changelog->get_parse_errors) {
     }
 }
 
+# Check for some things in the raw changelog file and compute the
+# "offset" to the first line of the first entry.  We use this to
+# report the line number of "too-long" lines.  (#657402)
+my $chloff = check_dch ($pkg, $type);
+
 my @entries = $changelog->data;
 if (@entries) {
     my %versions;
@@ -384,7 +389,7 @@ if (@entries) {
     for my $i (0 .. $#lines) {
         if (length($lines[$i]) > 81
             and $lines[$i] !~ /^[\s.o*+-]*(?:[Ss]ee:?\s+)?\S+$/) {
-            tag 'debian-changelog-line-too-long', 'line ' . ($i + 1);
+            tag 'debian-changelog-line-too-long', 'line ' . ($i + $chloff);
         }
     }
 
@@ -394,37 +399,54 @@ if (@entries) {
     check_spelling('spelling-error-in-changelog', $changes, undef, { $pkg => 1});
 }
 
-# read the changelog itself
+}
+
+# read the changelog itself and check for some issues we cannot find
+# with Parse::DebianChangelog.  Also return the "real" line number for
+# the first line of text in the first entry.
 #
-# emacs only looks at the last "local variables" in a file, and only at
-# one within 3000 chars of EOF and on the last page (^L), but that's a bit
-# pesky to replicate.  Demanding a match of $prefix and $suffix ought to
-# be enough to avoid false positives.
-open (IN, '<', 'changelog')
-    or fail("cannot find changelog for $type package $pkg");
-my ($prefix, $suffix);
-while (<IN>) {
-
-    if (/closes:\s*(((?:bug)?\#?\s?\d*)[[:alpha:]]\w*)/io
-        || /closes:\s*(?:bug)?\#?\s?\d+
+sub check_dch {
+    my ($pkg, $type) = @_;
+
+    # emacs only looks at the last "local variables" in a file, and only at
+    # one within 3000 chars of EOF and on the last page (^L), but that's a bit
+    # pesky to replicate.  Demanding a match of $prefix and $suffix ought to
+    # be enough to avoid false positives.
+
+    open (IN, '<', 'changelog')
+        or fail("cannot find changelog for $type package $pkg");
+    my ($prefix, $suffix);
+    my $lineno = 0;
+    my ($estart, $tstart) = (0, 0);
+    while (<IN>) {
+
+        unless ($tstart) {
+            $lineno++;
+            $estart = 1 if m/^\S/;
+            $tstart = 1 if m/^\s+\S/;
+        }
+
+        if (/closes:\s*(((?:bug)?\#?\s?\d*)[[:alpha:]]\w*)/io
+            || /closes:\s*(?:bug)?\#?\s?\d+
               (?:,\s*(?:bug)?\#?\s?\d+)*
               (?:,\s*(((?:bug)?\#?\s?\d*)[[:alpha:]]\w*))/iox) {
-        tag 'wrong-bug-number-in-closes', "l$.:$1" if $2;
-    }
+            tag 'wrong-bug-number-in-closes', "l$.:$1" if $2;
+        }
 
-    if (/^(.*)Local\ variables:(.*)$/i) {
-        $prefix = $1;
-        $suffix = $2;
-    }
-    # emacs allows whitespace between prefix and variable, hence \s*
-    if (defined $prefix && defined $suffix
-        && /^\Q$prefix\E\s*add-log-mailing-address:.*\Q$suffix\E$/) {
-        tag 'debian-changelog-file-contains-obsolete-user-emacs-settings';
+        if (/^(.*)Local\ variables:(.*)$/i) {
+            $prefix = $1;
+            $suffix = $2;
+        }
+        # emacs allows whitespace between prefix and variable, hence \s*
+        if (defined $prefix && defined $suffix
+               && /^\Q$prefix\E\s*add-log-mailing-address:.*\Q$suffix\E$/) {
+            tag 'debian-changelog-file-contains-obsolete-user-emacs-settings';
+        }
     }
+    close IN;
+    return $lineno;
 }
-close IN;
 
-}
 
 1;
 
diff --git a/debian/changelog b/debian/changelog
index 6d0bfce..68dcfa4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -37,6 +37,9 @@ lintian (2.5.7) UNRELEASED; urgency=low
     + [NT] Move embedded library data to a data file.
     + [NT] Add ELF hardening checks.  Thanks to Kees Cook for
       report and the patches.  (Closes: 650536)
+  * checks/changelog-file:
+    + [NT] Output the correct line number for the "line-too-long"
+      tag.  Thanks to Arno Töll for the report.  (Closes: #657402)
   * checks/changes-file{,.desc}:
     + [NT] Remove Ubuntu specific handling of distribution names.
       Instead replace it with a more generalized one that derivatives
diff --git a/t/tests/changelog-file-general/debian/debian/changelog.in b/t/tests/changelog-file-general/debian/debian/changelog.in
index 42da9c6..77e67b5 100644
--- a/t/tests/changelog-file-general/debian/debian/changelog.in
+++ b/t/tests/changelog-file-general/debian/debian/changelog.in
@@ -1,5 +1,6 @@
 {$srcpkg} ({$version}) unstable; urgency=low
 
+
   * Test: {$testname}
   * improbable-bug-number-in-closes (Closes: #12)
   * Another bug closer without a colon (Closes #555555)
@@ -9,6 +10,10 @@
     See http://www.example.com/but-a-really-long-url-does-not-count-as-a-long-line-at-all
     even if preceded by See.
 
+  * Here is another really long in the changelog, and it would be really nice if a
+    certain program would report its line number correctly.  Especially since,
+    we have an extra empty line in the start of the entry.
+
  -- {$author}  {$date}
 
 {$srcpkg} ({$version}) unstable; urgency=low
diff --git a/t/tests/changelog-file-general/tags b/t/tests/changelog-file-general/tags
index d568bd8..d72257e 100644
--- a/t/tests/changelog-file-general/tags
+++ b/t/tests/changelog-file-general/tags
@@ -2,9 +2,10 @@ E: changelog-file-general: debian-changelog-file-contains-invalid-email-address
 E: changelog-file-general: possible-missing-colon-in-closes Closes #555555
 W: changelog-file-general: changelog-not-compressed-with-max-compression changelog.Debian.gz
 W: changelog-file-general: debian-changelog-file-contains-obsolete-user-emacs-settings
-W: changelog-file-general: debian-changelog-line-too-long line 4
+W: changelog-file-general: debian-changelog-line-too-long line 13
+W: changelog-file-general: debian-changelog-line-too-long line 7
 W: changelog-file-general: improbable-bug-number-in-closes 12
 W: changelog-file-general: latest-debian-changelog-entry-without-new-date
 W: changelog-file-general: latest-debian-changelog-entry-without-new-version
-W: changelog-file-general: syntax-error-in-debian-changelog line 20 "badly formatted heading line"
-W: changelog-file-general: syntax-error-in-debian-changelog line 22 "found change data where expected next heading or eof"
+W: changelog-file-general: syntax-error-in-debian-changelog line 25 "badly formatted heading line"
+W: changelog-file-general: syntax-error-in-debian-changelog line 27 "found change data where expected next heading or eof"

-- 
Debian package checker


Reply to: