summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRaphaël Hertzog <hertzog@debian.org>2009-10-25 17:19:07 +0100
committerRaphaël Hertzog <hertzog@debian.org>2009-10-31 22:42:11 +0100
commitd0d812c1d96f53fdabbb356a50fc3a11cd7ce04d (patch)
tree3689615e2805f736c067e8022365752e46124340 /scripts
parentbb9af2d083538d4ffa2033b1e3380ec9d924d32b (diff)
downloaddpkg-d0d812c1d96f53fdabbb356a50fc3a11cd7ce04d.tar.gz
Dpkg::Changelog::Entry::Debian: parse changes lines as set of items
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.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Dpkg/Changelog/Entry/Debian.pm37
1 files changed, 37 insertions, 0 deletions
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