The branch, master has been updated
via 112bc4bf62d6b93da5e99b18b85de272341d1412 (commit)
via 83d4b9afc3e33c3c0f7a35af426eb796f1e9f87b (commit)
via 0a9be93dfd725928d5e9f2804a677fac3c9a2992 (commit)
from 0466c27ccb5a85d93261c5831d9258f6d1b5bb53 (commit)
- Shortlog ------------------------------------------------------------
112bc4b Fix input semantics of Debian changelog parser
83d4b9a Dpkg::Changelog: Allow input to come directly from a filehandle
0a9be93 Fix one format string
Summary of changes:
scripts/Dpkg/Changelog.pm | 12 ++++++++----
scripts/Dpkg/Changelog/Debian.pm | 12 ++++++++++--
scripts/changelog/debian.pl | 19 +++++++++++--------
scripts/dpkg-parsechangelog.pl | 2 +-
4 files changed, 30 insertions(+), 15 deletions(-)
-----------------------------------------------------------------------
Details of changes:
commit 112bc4bf62d6b93da5e99b18b85de272341d1412
Author: Frank Lichtenheld <[EMAIL PROTECTED]>
Date: Wed Jan 16 13:15:07 2008 +0100
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 6e3b64f..e90373a 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 <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 })
commit 83d4b9afc3e33c3c0f7a35af426eb796f1e9f87b
Author: Frank Lichtenheld <[EMAIL PROTECTED]>
Date: Wed Jan 16 13:08:51 2008 +0100
Dpkg::Changelog: Allow input to come directly from a filehandle
* scripts/Dpkg/Changelog/Debian.pm (parse): Accept input in
configuration item 'inhandle'. Allow to override the name of
the file (used for reporting) with configuration item
'reportfile'.
* scripts/Dpkg/Changelog.pm (init): Call parse if
'inhandle' is given.
diff --git a/scripts/Dpkg/Changelog.pm b/scripts/Dpkg/Changelog.pm
index 18db282..7d5b941 100644
--- a/scripts/Dpkg/Changelog.pm
+++ b/scripts/Dpkg/Changelog.pm
@@ -64,7 +64,7 @@ There are currently no supported general configuration
options, but
see the other methods for more specific configuration options which
can also specified to C<init>.
-If C<infile> or C<instring> are specified (see L<parse>), C<parse()>
+If C<infile>, C<inhandle>, or C<instring> are specified, C<parse()>
is called from C<init>. If a fatal error is encountered during parsing
(e.g. the file can't be opened), C<init> will not return a
valid object but C<undef>!
@@ -82,7 +82,9 @@ sub init {
$self->reset_parse_errors;
- if ($self->{config}{infile} || $self->{config}{instring}) {
+ if ($self->{config}{infile}
+ || $self->{config}{inhandle}
+ || $self->{config}{instring}) {
defined($self->parse) or return undef;
}
@@ -132,8 +134,10 @@ an array of arrays. Each of these arrays contains
=item 1.
-the filename of the parsed file or C<String> if a string was
-parsed directly
+the filename of the parsed file or C<FileHandle> or C<String>
+if the input came from a file handle or a string. If the
+reportfile configuration option was given, its value will be
+used instead
=item 2.
diff --git a/scripts/Dpkg/Changelog/Debian.pm b/scripts/Dpkg/Changelog/Debian.pm
index 7971466..2aa2687 100644
--- a/scripts/Dpkg/Changelog/Debian.pm
+++ b/scripts/Dpkg/Changelog/Debian.pm
@@ -74,8 +74,11 @@ use base qw(Dpkg::Changelog);
=head3 parse
-Parses either the file named in configuration item C<infile> or the string
-saved in configuration item C<instring>.
+Parses either the file named in configuration item C<infile>, the content
+of the filehandle in configuration item C<inhandle>, or the string
+saved in configuration item C<instring> (the latter requires IO::String).
+You can set a filename to use for reporting errors with configuration
+item C<reportfile>.
Accepts a hash ref as optional argument which can contain configuration
items.
@@ -99,6 +102,8 @@ sub parse {
$file, $! );
return undef;
};
+ } elsif ($fh = $self->{config}{inhandle}) {
+ $file = 'FileHandle';
} elsif (my $string = $self->{config}{instring}) {
eval { require IO::String };
if ($@) {
@@ -112,6 +117,9 @@ sub parse {
$self->_do_fatal_error(_g('no changelog file specified'));
return undef;
}
+ if (defined($self->{config}{reportfile})) {
+ $file = $self->{config}{reportfile};
+ }
$self->reset_parse_errors;
commit 0a9be93dfd725928d5e9f2804a677fac3c9a2992
Author: Frank Lichtenheld <[EMAIL PROTECTED]>
Date: Wed Jan 16 13:01:50 2008 +0100
Fix one format string
* scripts/dpkg-parsechangelog.pl: Remove one superfluous
%s from a formatstring which was used to output $! before
syserr() was used instead.
diff --git a/scripts/dpkg-parsechangelog.pl b/scripts/dpkg-parsechangelog.pl
index 26b0929..1ae3da2 100755
--- a/scripts/dpkg-parsechangelog.pl
+++ b/scripts/dpkg-parsechangelog.pl
@@ -117,7 +117,7 @@ defined($pf) || error(_g("format %s unknown"), $pa);
if ($changelogfile ne "-") {
open(STDIN,"<", $changelogfile)
- || syserr(_g("cannot open %s: %s"), $changelogfile);
+ || syserr(_g("cannot open %s"), $changelogfile);
}
exec($pf,@ap) || syserr(_g("cannot exec format parser: %s"));
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]