Package: libparse-debianchangelog-perl
Version: 1.1.1-2
Severity: normal
Hi,
Parse::DebianChangelog's parse method dies in for loops like:
for ("") { $foo->parse; }
but not in
for my $x ("") { $foo->parse; }
The first patch in the attached series localizes $_ to avoid this
problem. See also [1] for more information.
[1] http://www.perlmonks.org/?node_id=570712
I also attached a test case and updated the dependencies to include a
recent version of Test::More and Test::Exception.
Regards,
Ansgar
PS: The Git repository seems outdated. 1.1.1-2 is not there :(
>From cacc780bc2daceecff08e797485d45c3fb4ff638 Mon Sep 17 00:00:00 2001
From: Ansgar Burchardt <[email protected]>
Date: Tue, 8 Jun 2010 02:11:37 +0900
Subject: [PATCH 1/3] localize $_ to make parse method usable in for loops
---
lib/Parse/DebianChangelog.pm | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/lib/Parse/DebianChangelog.pm b/lib/Parse/DebianChangelog.pm
index 30186de..d801f53 100644
--- a/lib/Parse/DebianChangelog.pm
+++ b/lib/Parse/DebianChangelog.pm
@@ -309,6 +309,7 @@ sub parse {
my $blanklines = 0;
my $unknowncounter = 1; # to make version unique, e.g. for using as id
+ local $_;
while (<$fh>) {
s/\s*\n$//;
# printf(STDERR "%-39.39s %-39.39s\n",$expect,$_);
--
1.7.1
>From 543507c4cbcd38cec8af521e93e24cb94ef8f960 Mon Sep 17 00:00:00 2001
From: Ansgar Burchardt <[email protected]>
Date: Tue, 8 Jun 2010 02:12:22 +0900
Subject: [PATCH 2/3] add test case for parsing in for loop
---
t/parse-in-for-loop.t | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
create mode 100644 t/parse-in-for-loop.t
diff --git a/t/parse-in-for-loop.t b/t/parse-in-for-loop.t
new file mode 100644
index 0000000..ce21298
--- /dev/null
+++ b/t/parse-in-for-loop.t
@@ -0,0 +1,33 @@
+#! /usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More 0.88;
+use Test::Exception;
+
+use Parse::DebianChangelog;
+
+my $data = <<'EOT';
+package (1.2-1) unstable; urgency=low
+
+ * Initial release.
+
+ -- Ex A. Mple <[email protected]> Tue, 08 Jun 2010 01:50:16 +0900
+EOT
+
+{
+ my $parser = Parse::DebianChangelog->init;
+ for my $x ("") {
+ lives_ok { $parser->parse({ instring => $data }); } 'parse in for my $x
(...) works';
+ }
+}
+
+{
+ my $parser = Parse::DebianChangelog->init;
+ for ("") {
+ lives_ok { $parser->parse({ instring => $data }); } 'parse in for (...)
works';
+ }
+}
+
+done_testing;
--
1.7.1
>From 23d7f7567e2331a5761cf31cccf9e38262c3cd4b Mon Sep 17 00:00:00 2001
From: Ansgar Burchardt <[email protected]>
Date: Tue, 8 Jun 2010 02:16:05 +0900
Subject: [PATCH 3/3] add build-dependencies for new tests
---
debian/control | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/debian/control b/debian/control
index 6330d7c..2bc0c0d 100644
--- a/debian/control
+++ b/debian/control
@@ -2,7 +2,7 @@ Source: libparse-debianchangelog-perl
Section: perl
Priority: optional
Build-Depends: debhelper (>= 5)
-Build-Depends-Indep: perl (>= 5.8.0-7), po4a, libtimedate-perl,
libhtml-parser-perl, libhtml-template-perl, libclass-accessor-perl, tidy,
libxml-simple-perl, libio-string-perl, libmodule-build-perl, libtest-pod-perl,
libtest-pod-coverage-perl
+Build-Depends-Indep: perl (>= 5.8.0-7), po4a, libtimedate-perl,
libhtml-parser-perl, libhtml-template-perl, libclass-accessor-perl, tidy,
libxml-simple-perl, libio-string-perl, libmodule-build-perl, libtest-pod-perl,
libtest-pod-coverage-perl, perl (>= 5.10.1) | libtest-simple-perl (>= 0.88),
libtest-exception-perl
Maintainer: Frank Lichtenheld <[email protected]>
Standards-Version: 3.7.2
XS-Vcs-git: git://source.djpig.de/git/Parse-DebianChangelog.git
--
1.7.1