| 1 | # Copyright © 1996 Ian Jackson | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # Copyright © 2005 Frank Lichtenheld <frank@lichtenheld.de> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # Copyright © 2009 Raphaël Hertzog <hertzog@debian.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # Copyright © 2012-2017 Guillem Jover <guillem@debian.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # This program is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # the Free Software Foundation; either version 2 of the License, or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # (at your option) any later version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # This program is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # GNU General Public License for more details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # You should have received a copy of the GNU General Public License | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # along with this program. If not, see <https://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | Dpkg::Changelog::Debian - parse Debian changelogs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | This class represents a Debian changelog file as an array of changelog | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | entries (L<Dpkg::Changelog::Entry::Debian>). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | It implements the generic interface L<Dpkg::Changelog>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | Only methods specific to this implementation are described below, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | the rest are inherited. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | Dpkg::Changelog::Debian parses Debian changelogs as described in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | L<deb-changelog(5)>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | The parser tries to ignore most cruft like # or /* */ style comments, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | RCS keywords, Vim modelines, Emacs local variables and stuff from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | older changelogs with other formats at the end of the file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | NOTE: most of these are ignored silently currently, there is no | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | parser error issued for them. This should become configurable in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | future. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | package Dpkg::Changelog::Debian 1.00; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 2 | ▶ | use Dpkg::Gettext; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | ▶ | use Dpkg::File; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 2 | ▶ | use Dpkg::Changelog; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 2 | ▶ | use Dpkg::Changelog::Entry::Debian qw(match_header match_trailer); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 2 | ▶ | use parent qw(Dpkg::Changelog); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 2 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 2 | FIRST_HEADING => g_('first heading'), | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | NEXT_OR_EOF => g_('next heading or end of file'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | START_CHANGES => g_('start of change data'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | CHANGES_OR_TRAILER => g_('more change data or trailer'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 2 | my $ancient_delimiter_regex = qr{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | ^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | (?: # Ancient GNU style changelog entry with expanded date. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | \w+\s+ # Day of week (abbreviated). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | \w+\s+ # Month name (abbreviated). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | \d{1,2} # Day of month. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | \Q \E | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | \d{1,2}:\d{1,2}:\d{1,2}\s+ # Time. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | [\w\s]* # Timezone. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | \d{4} # Year. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | \s+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | (?:.*) # Maintainer name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | \s+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | [<\(] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | (?:.*) # Maintainer email. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | [\)>] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | | # Old GNU style changelog entry with expanded date. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | \w+\s+ # Day of week (abbreviated). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | \w+\s+ # Month name (abbreviated). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | \d{1,2},?\s* # Day of month. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | \d{4} # Year. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | \s+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | (?:.*) # Maintainer name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | \s+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | [<\(] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | (?:.*) # Maintainer email. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | [\)>] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | | # Ancient changelog header w/o key=value options. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | (?:\w[-+0-9a-z.]*) # Package name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | \Q \E | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | \( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | (?:[^\(\) \t]+) # Package version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | \) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | \;? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | | # Ancient changelog header. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | (?:[\w.+-]+) # Package name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | [- ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | (?:\S+) # Package version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | \ Debian | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | \ (?:\S+) # Package revision. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | Changes\ from\ version\ (?:.*)\ to\ (?:.*): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | Changes\ for\ [\w.+-]+-[\w.+-]+:?\s*$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | Old\ Changelog:\s*$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | (?:\d+:)? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | \w[\w.+~-]*:? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | \s*$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | }xi; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | =item $count = $chlog->parse($fh, $description) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | Read the filehandle and parse a Debian changelog in it, to store the entries | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | as an array of L<Dpkg::Changelog::Entry::Debian> objects. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | Any previous entries in the object are reset before parsing new data. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | Returns the number of changelog entries that have been parsed with success. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 16 | ▶ | sub parse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=35 SCAR=44.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 16 | my ($self, $fh, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 16 | ▶ | $file = $self->{reportfile} if exists $self->{reportfile}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 16 | $self->reset_parse_errors; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 16 | $self->{data} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 16 | $self->set_unparsed_tail(undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 16 | my $expect = FIRST_HEADING; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 16 | my $entry = Dpkg::Changelog::Entry::Debian->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 16 | my @blanklines = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | # To make version unique, for example for using as id. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 16 | my $unknowncounter = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 16 | local $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 16 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 3780 | chomp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 3780 | ▶ | if (match_header($_)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 12 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 250 | ▶ | unless ($expect eq FIRST_HEADING || $expect eq NEXT_OR_EOF) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$expect eq "first heading" or $expect eq "next heading or end of file"
MC/DC100%2/2
$expect eq "first heading" or $expect eq "next heading or end of file"
$expect eq "first heading"
$expect eq "next heading or end of file"
Truth table100%3/3
A or B
A= $expect eq "first heading"B= $expect eq "next heading or end of file"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 2 | $self->parse_error($file, $., | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | sprintf(g_('found start of entry where expected %s'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | $expect), "$_"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 250 | ▶ | unless ($entry->is_empty) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 234 | push @{$self->{data}}, $entry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 234 | $entry = Dpkg::Changelog::Entry::Debian->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 234 | ▶ | last if $self->abort_early(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 250 | $entry->set_part('header', $_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 250 | foreach my $error ($entry->parse_header()) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | $self->parse_error($file, $., $error, $_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 250 | $expect = START_CHANGES; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 250 | @blanklines = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } elsif (m/^(?:;;\s*)?Local variables:/io) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | # Save any trailing Emacs variables at end of file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | $self->set_unparsed_tail("$_\n" . (file_slurp($fh) // '')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
file_slurp($fh) // ""
MC/DC0%0/1
file_slurp($fh) // ""
file_slurp($fh)
Truth table0%0/2
A
A= file_slurp($fh)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } elsif (m/^vim:/io) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | # Save any trailing Vim modelines at end of file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 2 | ▶ | $self->set_unparsed_tail("$_\n" . (file_slurp($fh) // '')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
file_slurp($fh) // ""
MC/DC0%0/1
file_slurp($fh) // ""
file_slurp($fh)
Truth table50%1/2
A
A= file_slurp($fh)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 2 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } elsif (m/^\$\w+:.*\$/o) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | # Skip stuff that look like a RCS keyword. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } elsif (m/^\# /o) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | # Skip comments, even that is not supported. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } elsif (m{^/\*.*\*/}o) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | # More comments. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } elsif (m/$ancient_delimiter_regex/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | # Save entries on old changelog format verbatim. We assume the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | # rest of the file will be in old format once we hit it for the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | # first time. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 2 | $self->set_unparsed_tail("$_\n" . file_slurp($fh)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } elsif (m/^\S/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 2 | $self->parse_error($file, $., g_('badly formatted heading line'), "$_"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } elsif (match_trailer($_)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 248 | ▶ | unless ($expect eq CHANGES_OR_TRAILER) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $self->parse_error($file, $., | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | sprintf(g_('found trailer where expected %s'), $expect), "$_"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 248 | $entry->set_part('trailer', $_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 248 | $entry->extend_part('blank_after_changes', [ @blanklines ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 248 | @blanklines = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 248 | foreach my $error ($entry->parse_trailer()) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $self->parse_error($file, $., $error, $_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 248 | $expect = NEXT_OR_EOF; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } elsif (m/^ --/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 2 | $self->parse_error($file, $., g_('badly formatted trailer line'), "$_"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } elsif (m/^\s{2,}(?:\S)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 2534 | ▶ | unless ($expect eq START_CHANGES or $expect eq CHANGES_OR_TRAILER) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$expect eq "start of change data" or $expect eq "more change data or trailer"
MC/DC0%0/2
$expect eq "start of change data" or $expect eq "more change data or trailer"
$expect eq "start of change data"
$expect eq "more change data or trailer"
Truth table66%2/3
A or B
A= $expect eq "start of change data"B= $expect eq "more change data or trailer"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $self->parse_error($file, $., sprintf(g_('found change data' . | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | ' where expected %s'), $expect), "$_"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | if ($expect eq NEXT_OR_EOF and not $entry->is_empty) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$expect eq "next heading or end of file" and not $entry->is_empty
MC/DC0%0/2
$expect eq "next heading or end of file" and not $entry->is_empty
$expect eq "next heading or end of file"
not $entry->is_empty
Truth table0%0/3
A and not(B)
A= $expect eq "next heading or end of file"B= not $entry->is_empty
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # Let us assume we have missed the actual header line. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | push @{$self->{data}}, $entry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | $entry = Dpkg::Changelog::Entry::Debian->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $entry->set_part('header', 'unknown (unknown' . ($unknowncounter++) . ') unknown; urgency=unknown'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | # Keep raw changes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 2534 | $entry->extend_part('changes', [ @blanklines, $_ ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 2534 | @blanklines = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 2534 | $expect = CHANGES_OR_TRAILER; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } elsif (! m/\S/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 740 | ▶ | if ($expect eq START_CHANGES) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 246 | $entry->extend_part('blank_after_header', $_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 246 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } elsif ($expect eq NEXT_OR_EOF) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 238 | $entry->extend_part('blank_after_trailer', $_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 238 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } elsif ($expect ne CHANGES_OR_TRAILER) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | $self->parse_error($file, $., | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | sprintf(g_('found blank line where expected %s'), $expect)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 256 | push @blanklines, $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $self->parse_error($file, $., g_('unrecognized line'), "$_"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | unless ($expect eq START_CHANGES or $expect eq CHANGES_OR_TRAILER) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$expect eq "start of change data" or $expect eq "more change data or trailer"
MC/DC0%0/2
$expect eq "start of change data" or $expect eq "more change data or trailer"
$expect eq "start of change data"
$expect eq "more change data or trailer"
Truth table0%0/3
A or B
A= $expect eq "start of change data"B= $expect eq "more change data or trailer"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | # Let us assume change data if we expected it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | $entry->extend_part('changes', [ @blanklines, $_]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | @blanklines = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | $expect = CHANGES_OR_TRAILER; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 16 | ▶ | unless ($expect eq NEXT_OR_EOF) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | $self->parse_error($file, $., | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | sprintf(g_('found end of file where expected %s'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | $expect)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 16 | ▶ | unless ($entry->is_empty) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 16 | push @{$self->{data}}, $entry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 16 | return scalar @{$self->{data}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | =head1 CHANGES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | =head2 Version 1.00 (dpkg 1.15.6) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | Mark the module as public. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | L<Dpkg::Changelog>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||