This file is indexed.

/usr/share/perl5/Parse/DebianChangelog/Util.pm is in libparse-debianchangelog-perl 1.2.0-8.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#
# Parse::DebianChangelog::Util
#
# Copyright 1996 Ian Jackson
# Copyright 2005 Frank Lichtenheld <frank@lichtenheld.de>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
#

=head1 NAME

Parse::DebianChangelog::Util - utility functions for parsing Debian changelogs

=head1 DESCRIPTION

This is currently only used internally by Parse::DebianChangelog.
There may be still API changes until this module is finalized.

=head2 Functions

=cut

package Parse::DebianChangelog::Util;

use strict;
use warnings;

require Exporter;

our @ISA = qw(Exporter);

our %EXPORT_TAGS = ( 'all' => [ qw(
		 find_closes
		 data2rfc822
		 data2rfc822_mult
		 get_dpkg_changes
) ] );

our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );

our @EXPORT = qw(
);

=pod

=head3 find_closes

Takes one string as argument and finds "Closes: #123456, #654321" statements
as supported by the Debian Archive software in it. Returns all closed bug
numbers in an array reference.

=cut

sub find_closes {
    my $changes = shift;
    my @closes = ();

    while ($changes && ($changes =~ /closes:\s*(?:bug)?\#?\s?\d+(?:,\s*(?:bug)?\#?\s?\d+)*/ig)) {
	push(@closes, $& =~ /\#?\s?(\d+)/g);
    }

    @closes = sort { $a <=> $b } @closes;
    return \@closes;
}

=pod

=head3 data2rfc822

Takes two hash references as arguments. The first should contain the
data to output in RFC822 format. The second can contain a sorting order
for the fields. The higher the numerical value of the hash value, the
earlier the field is printed if it exists.

Return the data in RFC822 format as string.

=cut

sub data2rfc822 {
    my ($data, $fieldimps) = @_;
    my $rfc822_str = '';

# based on /usr/lib/dpkg/controllib.pl
    for my $f (sort { $fieldimps->{$b} <=> $fieldimps->{$a} } keys %$data) {
	my $v= $data->{$f} or next;
	$v =~ m/\S/o || next; # delete whitespace-only fields
	$v =~ m/\n\S/o
	    && warn(__g("field %s has newline then non whitespace >%s<",
			$f, $v ));
	$v =~ m/\n[ \t]*\n/o && warn(__g("field %s has blank lines >%s<",
					 $f, $v ));
	$v =~ m/\n$/o && warn(__g("field %s has trailing newline >%s<",
				  $f, $v ));
	$v =~ s/\$\{\}/\$/go;
        # the changes have a space followed by a newline which was resulting
        # in a trailing space on "Changes: ". This caused the library to not
        # match the output of dpkg-parsechangelog
        $v = ' ' . $v if $v !~ m/^\s+/;
	$rfc822_str .= "$f:$v\n";
    }

    return $rfc822_str;
}

=pod

=head3 data2rfc822_mult

The first argument should be an array ref to an array of hash references.
The second argument is a hash reference and has the same meaning as
the second argument of L<data2rfc822>.

Calls L<data2rfc822> for each element of the array given as first
argument and returns the concatenated results.

=cut

sub data2rfc822_mult {
    my ($data, $fieldimps) = @_;
    my @rfc822 = ();

    foreach my $entry (@$data) {
	push @rfc822, data2rfc822($entry,$fieldimps);
    }

    return join "\n", @rfc822;
}

=pod

=head3 get_dpkg_changes

Takes a Parse::DebianChangelog::Entry object as first argument.

Returns a string that is suitable for using it in a C<Changes> field
in the output format of C<dpkg-parsechangelog>.

=cut

sub get_dpkg_changes {
    my $changes = "\n ".($_[0]->Header||'')."\n .\n".($_[0]->Changes||'');
    chomp $changes;
    $changes =~ s/^ $/ ./mgo;
    return $changes;
}

1;
__END__

=head1 SEE ALSO

Parse::DebianChangelog, Parse::DebianChangelog::Entry

=head1 AUTHOR

Frank Lichtenheld, E<lt>frank@lichtenheld.deE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2005 by Frank Lichtenheld

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

=cut