From d0d812c1d96f53fdabbb356a50fc3a11cd7ce04d Mon Sep 17 00:00:00 2001 From: Raphaël Hertzog Date: Sun, 25 Oct 2009 17:19:07 +0100 Subject: Dpkg::Changelog::Entry::Debian: parse changes lines as set of items MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The function get_change_items() reintroduce the feature that parsed the changes as a set of items describing individual changes. Furthermore it parses attribution lines (“[ Name ]”) as separate items. --- scripts/Dpkg/Changelog/Entry/Debian.pm | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'scripts') diff --git a/scripts/Dpkg/Changelog/Entry/Debian.pm b/scripts/Dpkg/Changelog/Entry/Debian.pm index 82312ff55..ce3d30890 100644 --- a/scripts/Dpkg/Changelog/Entry/Debian.pm +++ b/scripts/Dpkg/Changelog/Entry/Debian.pm @@ -58,6 +58,43 @@ our $regex_trailer = qr/^ \-\- (.*) <(.*)>( ?)((\w+\,\s*)?\d{1,2}\s+\w+\s+\d{4} =over 4 +=item my @items = $entry->get_change_items() + +Return a list of change items. Each item contains at least one line. +A change line starting with an asterisk denotes the start of a new item. +Any change line like "[ Raphael Hertzog ]" is treated like an item of its +own even if it starts a set of items attributed to this person (the +following line necessarily starts a new item). + +=cut + +sub get_change_items { + my ($self) = @_; + my (@items, @blanks, $item); + foreach my $line (@{$self->get_part("changes")}) { + if ($line =~ /^\s*\*/) { + push @items, $item if defined $item; + $item = "$line\n"; + } elsif ($line =~ /^\s*\[\s[^\]]+\s\]\s*$/) { + push @items, $item if defined $item; + push @items, "$line\n"; + $item = undef; + @blanks = (); + } elsif ($line =~ /^\s*$/) { + push @blanks, "$line\n"; + } else { + if (defined $item) { + $item .= "@blanks$line\n"; + } else { + $item = "$line\n"; + } + @blanks = (); + } + } + push @items, $item if defined $item; + return @items; +} + =item $entry->normalize() Normalize the content. Strip whitespaces at end of lines, use a single -- cgit v1.2.3