Просмотр исходного кода

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.
Frank Lichtenheld лет назад: 18
Родитель
Сommit
112bc4bf62
1 измененных файлов с 11 добавлено и 8 удалено
  1. 11 8
      scripts/changelog/debian.pl

+ 11 - 8
scripts/changelog/debian.pl

@@ -34,8 +34,10 @@ sub usage {
 Options:
     --help, -h                  print usage information
     --version, -V               print version information
-    --file, -l <file>           changelog file to parse, defaults
-                                to 'debian/changelog'
+    --label, -l <file>          name of the changelog file to
+                                use in error messages
+    --file <file>               changelog file to parse, defaults
+                                to '-' (standard input)
     --format <outputformat>     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 = <STDIN>;
-    $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 })