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

Dpkg::Changelog::Debian: store unmodified changes lines in an array

And post-process them later for output as a proper Dpkg::Control
information block.
Raphaël Hertzog лет назад: 17
Родитель
Сommit
47b4a76467
2 измененных файлов с 17 добавлено и 10 удалено
  1. 9 2
      scripts/Dpkg/Changelog.pm
  2. 8 8
      scripts/Dpkg/Changelog/Debian.pm

+ 9 - 2
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;
 }
 

+ 8 - 8
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;
     }