The following commit has been merged in the master branch:
commit 47b4a7646705e571cc29cb86ba2b4dd3e697681c
Author: Raphaël Hertzog <[email protected]>
Date:   Thu Oct 8 15:42:03 2009 +0200

    Dpkg::Changelog::Debian: store unmodified changes lines in an array
    
    And post-process them later for output as a proper Dpkg::Control
    information block.

diff --git a/scripts/Dpkg/Changelog.pm b/scripts/Dpkg/Changelog.pm
index 661a60e..0792004 100644
--- a/scripts/Dpkg/Changelog.pm
+++ b/scripts/Dpkg/Changelog.pm
@@ -771,9 +771,16 @@ in the output format of C<dpkg-parsechangelog>.
 =cut
 
 sub get_dpkg_changes {
-    my $changes = "\n ".($_[0]->{Header}||'')."\n .\n".($_[0]->{Changes}||'');
+    my $entry = shift;
+    my $changes = "\n " . ($entry->{Header} || '') . "\n .\n";
+    foreach my $line (@{$entry->{Changes}}) {
+       if ($line =~ /^\s*$/) {
+           $changes .= " .\n";
+       } else {
+           $changes .= " $line\n";
+       }
+    }
     chomp $changes;
-    $changes =~ s/^ $/ ./mgo;
     return $changes;
 }
 
diff --git a/scripts/Dpkg/Changelog/Debian.pm b/scripts/Dpkg/Changelog/Debian.pm
index f891f79..4e89338 100644
--- a/scripts/Dpkg/Changelog/Debian.pm
+++ b/scripts/Dpkg/Changelog/Debian.pm
@@ -144,7 +144,7 @@ sub parse {
                $self->_do_parse_error(@{$entry->{ERROR}});
            }
            unless ($entry->is_empty) {
-               $entry->{'Closes'} = find_closes( $entry->{Changes} );
+               $entry->{'Closes'} = find_closes(join("\n", 
@{$entry->{Changes}}));
 #                  print STDERR, Dumper($entry);
                push @{$self->{data}}, $entry;
                $entry = new Dpkg::Changelog::Entry;
@@ -155,7 +155,8 @@ sub parse {
                $entry->{'Version'} = "$2";
                $entry->{'Header'} = "$_";
                ($entry->{'Distribution'} = "$3") =~ s/^\s+//;
-               $entry->{'Changes'} = $entry->{'Urgency_comment'} = '';
+               $entry->{'Changes'} = [];
+               $entry->{'Urgency_comment'} = '';
                $entry->{'Urgency'} = $entry->{'Urgency_lc'} = 'unknown';
            }
            (my $rhs = $POSTMATCH) =~ s/^\s+//;
@@ -253,7 +254,7 @@ sub parse {
                    if (($expect eq 'next heading or eof')
                        && !$entry->is_empty) {
                        # lets assume we have missed the actual header line
-                       $entry->{'Closes'} = find_closes( $entry->{Changes} );
+                       $entry->{'Closes'} = find_closes(join("\n", 
@{$entry->{Changes}}));
 #                  print STDERR, Dumper($entry);
                        push @{$self->{data}}, $entry;
                        $entry = new Dpkg::Changelog::Entry;
@@ -267,8 +268,8 @@ sub parse {
                                                    $expect), "$_" ];
                    }
                };
-           $entry->{'Changes'} .= ($entry->{'Changes'} ? "\n" : "") .
-                                   (" .\n" x $blanklines) . " $_";
+           # Keep raw changes
+           push @{$entry->{'Changes'}}, ("") x $blanklines, $_;
            if (!$entry->{'Items'} || ($1 eq '*')) {
                $entry->{'Items'} ||= [];
                push @{$entry->{'Items'}}, "$_\n";
@@ -292,8 +293,7 @@ sub parse {
                || $expect eq 'more change data or trailer')
                && do {
                    # lets assume change data if we expected it
-                   $entry->{'Changes'} .= ($entry->{'Changes'} ? "\n" : "") .
-                                           (" .\n" x $blanklines) . " $_";
+                   push @{$entry->{'Changes'}}, ("") x $blanklines, $_;
                    if (!$entry->{'Items'}) {
                        $entry->{'Items'} ||= [];
                        push @{$entry->{'Items'}}, "$_\n";
@@ -316,7 +316,7 @@ sub parse {
            $self->_do_parse_error( @{$entry->{ERROR}} );
        };
     unless ($entry->is_empty) {
-       $entry->{'Closes'} = find_closes( $entry->{Changes} );
+       $entry->{'Closes'} = find_closes(join("\n", @{$entry->{Changes}}));
        push @{$self->{data}}, $entry;
     }
 

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to