From: Frank Lichtenheld Date: Wed, 16 Jan 2008 12:15:07 +0000 (+0100) Subject: Fix input semantics of Debian changelog parser X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=112bc4bf62d6b93da5e99b18b85de272341d1412;p=dpkg Fix input semantics of Debian changelog parser * scripts/changelog/debian.pl: Restore the old default behaviour to parse STDIN. Also fix the -l option to specify a label for the parsed input, but the actual file. Still allow --file to be used for that. Use the new inhandle option of parse() to pass STDIN directly. This should be faster and removes the implicit dependency on IO::String. --- diff --git a/scripts/changelog/debian.pl b/scripts/changelog/debian.pl index 6e3b64f9..e90373a8 100755 --- a/scripts/changelog/debian.pl +++ b/scripts/changelog/debian.pl @@ -34,8 +34,10 @@ sub usage { Options: --help, -h print usage information --version, -V print version information - --file, -l changelog file to parse, defaults - to 'debian/changelog' + --label, -l name of the changelog file to + use in error messages + --file changelog file to parse, defaults + to '-' (standard input) --format see man page for list of available output formats, defaults to 'dpkg' for compatibility with dpkg-dev @@ -54,8 +56,8 @@ Options: "), $progname; } -my ( $since, $until, $from, $to, $all, $count, $offset, $file ); -my $default_file = 'debian/changelog'; +my ( $since, $until, $from, $to, $all, $count, $offset, $file, $label ); +my $default_file = '-'; my $format = 'dpkg'; my %allowed_formats = ( dpkg => 1, @@ -72,7 +74,8 @@ sub set_format { $format = $val; } -GetOptions( "file|l=s" => \$file, +GetOptions( "file=s" => \$file, + "label|l=s" => \$label, "since|v=s" => \$since, "until|u=s" => \$until, "from|f=s" => \$from, @@ -99,6 +102,7 @@ if (@ARGV) { my $changes = Dpkg::Changelog::Debian->init(); $file ||= $default_file; +$label ||= $file; unless ($since or $until or $from or $to or $offset or $count or $all) { $count = 1; @@ -107,11 +111,10 @@ my @all = $all ? ( all => $all ) : (); my $opts = { since => $since, until => $until, from => $from, to => $to, count => $count, offset => $offset, - @all }; + @all, reportfile => $label }; if ($file eq '-') { - my @input = ; - $changes->parse({ instring => join('', @input), %$opts }) + $changes->parse({ inhandle => \*STDIN, %$opts }) or failure(_g('fatal error occured while parsing input')); } else { $changes->parse({ infile => $file, %$opts })