Author: djpig
Date: 2005-07-23 13:30:11 +0200 (Sat, 23 Jul 2005)
New Revision: 447

Modified:
   trunk/checks/changelog-file
   trunk/checks/changelog-file.desc
   trunk/debian/changelog
   trunk/debian/control
   trunk/testset/tags.binary
   trunk/testset/tags.filenames
Log:
Use libparse-debianchangelog-perl to parse the changelog
which detects a lot of syntax errors


Modified: trunk/checks/changelog-file
===================================================================
--- trunk/checks/changelog-file 2005-07-23 10:45:33 UTC (rev 446)
+++ trunk/checks/changelog-file 2005-07-23 11:30:11 UTC (rev 447)
@@ -22,6 +22,7 @@
 use strict;
 use Tags;
 use Util;
+use Parse::DebianChangelog;
 
 sub run {
 
@@ -212,6 +213,36 @@
     tag "debian-changelog-file-uses-obsolete-national-encoding", "at line 
$line"
 }
 
+my $changes = Parse::DebianChangelog->init( { infile => 'changelog',
+                                             quiet => 1 } );
+if (my @errors = $changes->get_parse_errors) {
+    foreach (@errors) {
+       tag "syntax-error-in-debian-changelog", "line $_->[1]", "\"$_->[2]\"";
+    }
+}
+
+my @entries = $changes->data;
+if (@entries) {
+    foreach (@entries) {
+       if ($_->Maintainer =~ /<([^>[EMAIL PROTECTED]@unknown)>/) {
+           tag "debian-changelog-file-contains-debmake-default-email-address", 
$1;
+       } elsif ($_->Maintainer =~ /<([^>[EMAIL PROTECTED]@[^>.]*)>/) {
+           tag "debian-changelog-file-contains-invalid-email-address", $1;
+       }
+    }
+
+    if (@entries > 1) {
+       my $first_timestamp = ($changes->data)[0]->Timestamp;
+       my $second_timestamp = ($changes->data)[1]->Timestamp;
+
+       if ( $first_timestamp && $second_timestamp ) {
+           tag "latest-debian-changelog-entry-without-new-date"
+               unless (($first_timestamp - $second_timestamp) > 0);
+       }
+    }
+}
+
+
 # read the changelog itself
 #
 # emacs only looks at the last "local variables:" in a file, and only at
@@ -219,49 +250,21 @@
 # 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, $first_entry_date, $second_entry_date);
+my ($prefix, $suffix);
 while (<IN>) {
-    if (/^ -- .+>  (.+?)$/) {
-       if (!$first_entry_date) {
-           $first_entry_date = $1;
-       } elsif (!$second_entry_date) {
-           $second_entry_date = $1;
-       }
-    }
-
     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$/) {
+    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 (/^\s*--[^<]*<([^>[EMAIL PROTECTED]@unknown)>/) {
-       tag "debian-changelog-file-contains-debmake-default-email-address", $1;
-    } elsif (/^\s*--[^<]*<([^>[EMAIL PROTECTED]@[^>.]*)>/) {
-       tag "debian-changelog-file-contains-invalid-email-address", $1;
-    }
 }
 close IN;
 
-if ($first_entry_date && $second_entry_date) {
-    my ($first_timestamp, $second_timestamp);
-    chomp($first_timestamp = `/bin/date -d "$first_entry_date" +\%s 
2>/dev/null`);
-    chomp($second_timestamp = `/bin/date -d "$second_entry_date" +\%s 
2>/dev/null`);
-
-    unless ( $first_timestamp && $second_timestamp ) {
-       tag "invalid-date-in-changelog", $first_entry_date 
-           unless $first_timestamp;
-       
-       tag "invalid-date-in-changelog", $second_entry_date 
-           unless $second_timestamp;
-    } else {
-       tag "latest-debian-changelog-entry-without-new-date" 
-           unless (($first_timestamp - $second_timestamp) > 0);
-    }
 }
-}
 
 1;
 

Modified: trunk/checks/changelog-file.desc
===================================================================
--- trunk/checks/changelog-file.desc    2005-07-23 10:45:33 UTC (rev 446)
+++ trunk/checks/changelog-file.desc    2005-07-23 11:30:11 UTC (rev 447)
@@ -107,13 +107,11 @@
   $ iconv -f ISO-8859-1 -t UTF-8 changelog > changelog.new
   $ mv changelog.new changelog
 
-Tag: invalid-date-in-changelog
-Type: warning
-Info: /bin/date couldn't parse the date of one of your changelog
- entries. The date should be in RFC822 format.
-Ref: policy 4.4
-
 Tag: latest-debian-changelog-entry-without-new-date
 Type: warning
 Info: The latest Debian changelog has either the same or even an older date
  as the entry before.
+
+Tag: syntax-error-in-debian-changelog
+Type: warning
+Info: While parsing the Debian changelog, an syntax error was found.

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog      2005-07-23 10:45:33 UTC (rev 446)
+++ trunk/debian/changelog      2005-07-23 11:30:11 UTC (rev 447)
@@ -1,5 +1,13 @@
 lintian (1.23.11) UNRELEASED; urgency=low
 
+  * debian/control:
+    + [FL] Depend on libparse-debianchangelog-perl, require
+      >= 0.6 since prior versions have bugs regarding parse
+      error handling
+  
+  * checks/changelog-file{,.desc}:
+    + [FL] Use libparse-debianchangelog-perl to parse the changelog,
+      which detects a lot of syntax errors
   * checks/common_data.pm:
     + [FL] Fix typo (hurd-386 -> hurd-i386) from last release
       that lead to spurious warnings about unknown architectures

Modified: trunk/debian/control
===================================================================
--- trunk/debian/control        2005-07-23 10:45:33 UTC (rev 446)
+++ trunk/debian/control        2005-07-23 11:30:11 UTC (rev 447)
@@ -9,7 +9,7 @@
 
 Package: lintian
 Architecture: all
-Depends: perl, libdigest-md5-perl | perl (>> 5.8), file, binutils, diffstat 
(>= 1.27-1), man-db (>= 2.3.20-1), gettext, intltool-debian
+Depends: perl, libdigest-md5-perl | perl (>> 5.8), file, binutils, diffstat 
(>= 1.27-1), man-db (>= 2.3.20-1), gettext, intltool-debian, 
libparse-debianchangelog-perl (>= 0.6)
 Suggests: binutils-multiarch
 Description: Debian package checker
  Lintian dissects Debian packages and reports bugs and policy

Modified: trunk/testset/tags.binary
===================================================================
--- trunk/testset/tags.binary   2005-07-23 10:45:33 UTC (rev 446)
+++ trunk/testset/tags.binary   2005-07-23 11:30:11 UTC (rev 447)
@@ -32,7 +32,6 @@
 W: binary: binary-without-manpage static-hello
 W: binary: executable-not-elf-or-script ./usr/bin/iminusrbin
 W: binary: file-in-unusual-dir usr/bar
-W: binary: invalid-date-in-changelog The, 15 Apr 2004 23:33:51 +0200
 W: binary: menu-command-not-in-package /usr/lib/menu/binary:6 /imnothere
 W: binary: menu-command-not-in-package /usr/share/menu/binary:6 /imnothere
 W: binary: menu-file-in-usr-lib usr/lib/menu/binary
@@ -40,6 +39,7 @@
 W: binary: menu-item-needs-tag-has-unknown-value wm /usr/share/menu/binary:5
 W: binary: package-contains-hardlink usr/bar2 -> usr/share/baz
 W: binary: package-contains-upstream-install-documentation 
usr/share/doc/binary/INSTALL
+W: binary: syntax-error-in-debian-changelog line 16 "couldn't parse date The, 
15 Apr 2004 23:33:51 +0200"
 W: binary: unquoted-string-in-menu-item /usr/lib/menu/binary needs:1
 W: binary: unquoted-string-in-menu-item /usr/lib/menu/binary needs:2
 W: binary: unquoted-string-in-menu-item /usr/share/menu/binary needs:1

Modified: trunk/testset/tags.filenames
===================================================================
--- trunk/testset/tags.filenames        2005-07-23 10:45:33 UTC (rev 446)
+++ trunk/testset/tags.filenames        2005-07-23 11:30:11 UTC (rev 447)
@@ -59,6 +59,7 @@
 W: filenames: symlink-is-self-recursive usr/lib/filenames/symlink5ok+warn ..
 W: filenames: symlink-is-self-recursive usr/lib/filenames/symlink6ok+warn .
 W: filenames: symlink-is-self-recursive usr/lib/filenames/symlink7ok+warn /
+W: filenames: syntax-error-in-debian-changelog line 0 "found eof where 
expected first heading"
 W: filenames: zero-byte-file-in-doc-directory 
usr/share/doc/filenames/Changes.gz
 W: filenames: zero-byte-file-in-doc-directory 
usr/share/doc/filenames/README.macosx
 W: filenames: zero-byte-file-in-doc-directory 
usr/share/doc/filenames/examples/very_interesting_example


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to