Przeglądaj źródła

Dpkg::Changelog::Debian: preserve blank lines

The blank lines separating the header, changes and trailer lines
were lost in the parsing. Now they are stored in three new attributes
of Dpkg::Changelog::Entry.
Raphaël Hertzog 17 lat temu
rodzic
commit
2a194c6cc6
2 zmienionych plików z 17 dodań i 6 usunięć
  1. 2 0
      scripts/Dpkg/Changelog.pm
  2. 15 6
      scripts/Dpkg/Changelog/Debian.pm

+ 2 - 0
scripts/Dpkg/Changelog.pm

@@ -500,6 +500,8 @@ BEGIN {
     @CHANGELOG_FIELDS = qw(Source Version Distribution
                            Urgency Maintainer Date Closes Changes
                            Timestamp Header Items Trailer
+			   BlankAfterHeader BlankAfterChanges
+			   BlankAfterTrailer
                            Urgency_comment Urgency_lc);
     $CHANGELOG_FIELDS = Dpkg::Control->new(type => CTRL_CHANGELOG);
     %$CHANGELOG_FIELDS = map { $_ => 1 } @CHANGELOG_FIELDS;

+ 15 - 6
scripts/Dpkg/Changelog/Debian.pm

@@ -156,6 +156,9 @@ sub parse {
 		$entry->{'Header'} = "$_";
 		($entry->{'Distribution'} = "$3") =~ s/^\s+//;
 		$entry->{'Changes'} = [];
+		$entry->{'BlankAfterHeader'} = [];
+		$entry->{'BlankAfterChanges'} = [];
+		$entry->{'BlankAfterTrailer'} = [];
 		$entry->{'Urgency_comment'} = '';
 		$entry->{'Urgency'} = $entry->{'Urgency_lc'} = 'unknown';
 	    }
@@ -226,6 +229,8 @@ sub parse {
 				       _g( "badly formatted trailer line" ),
 				       "$_");
 	    }
+	    push @{$entry->{BlankAfterChanges}}, @blanklines;
+	    @blanklines = ();
 	    $entry->{'Trailer'} = $_;
 	    $entry->{'Maintainer'} = "$1 <$2>" unless $entry->{'Maintainer'};
 	    unless($entry->{'Date'} && defined $entry->{'Timestamp'}) {
@@ -281,12 +286,16 @@ sub parse {
 	    @blanklines = ();
 	    $expect = 'more change data or trailer';
 	} elsif (!m/\S/) {
-	    next if $expect eq 'start of change data'
-		|| $expect eq 'next heading or eof';
-	    $expect eq 'more change data or trailer'
-		|| $self->_do_parse_error($file, $NR,
-					  sprintf(_g("found blank line where expected %s"),
-						  $expect));
+	    if ($expect eq 'start of change data') {
+		push @{$entry->{BlankAfterHeader}}, $_;
+		next;
+	    } elsif ($expect eq 'next heading or eof') {
+		push @{$entry->{BlankAfterTrailer}}, $_;
+		next;
+	    } elsif ($expect ne 'more change data or trailer') {
+		$self->_do_parse_error($file, $NR,
+		      sprintf(_g("found blank line where expected %s"), $expect));
+	    }
 	    push @blanklines, $_;
 	} else {
 	    $self->_do_parse_error($file, $NR, _g( "unrecognised line" ),