Subject: | xgettext '-f' option is broken |
Hi,
as reported in Debian bug #307777, http://bugs.debian.org/307777 , the
Locale::Maketext::Extract::Run() function can't handle newline-separated
input for the '-f' option. This is fixed by chomp()ing the filenames.
I'm attaching a patch and a crude testcase for this.
Cheers,
--
Niko Tyni (on behalf of the Debian Perl Group)
ntyni@debian.org
Subject: | 307777.patch |
diff --git a/lib/Locale/Maketext/Extract/Run.pm b/lib/Locale/Maketext/Extract/Run.pm
index 205d5dd..3a6e7c0 100644
--- a/lib/Locale/Maketext/Extract/Run.pm
+++ b/lib/Locale/Maketext/Extract/Run.pm
@@ -52,6 +52,7 @@ sub run {
foreach my $file (@{$opts{f}||[]}) {
open FILE, $file or die "Cannot open $file: $!";
while (<FILE>) {
+ chomp;
push @ARGV, $_ if -r and !-d;
}
}
diff --git a/t/7-runextract.t b/t/7-runextract.t
new file mode 100644
index 0000000..f751906
--- /dev/null
+++ b/t/7-runextract.t
@@ -0,0 +1,28 @@
+#! /usr/bin/perl -w
+use lib '../lib';
+use strict;
+use Test::More tests => 2;
+
+# test if the xgettext '-f' parameter stripts newlines from the filenames
+# http://bugs.debian.org/307777
+
+use_ok('Locale::Maketext::Extract::Run');
+
+my $inputfile = "$$.in";
+my $listfile = "$$.list";
+my $outfile = "$$.out";
+
+open(F, ">$inputfile") or die("create $inputfile failed: $!");
+print F "loc('test')";
+close F;
+
+open(F, ">$listfile") or die("create $inputfile failed: $!");
+print F "$inputfile\n/dev/null";
+close F;
+
+Locale::Maketext::Extract::Run::xgettext('-f', $listfile, '-o', $outfile);
+
+ok(-s $outfile, "non-empty output for Locale::Maketext::Extract::Run::xgettext");
+
+unlink $_ for ($inputfile, $listfile, $outfile);
+