This way we make sure we don't affect the $_ value for the caller, in case it was being used.
@@ -12,6 +12,7 @@ dpkg (1.17.7) UNRELEASED; urgency=low
dpkg-maintscript-helper(1). Closes: #739388
* Use exit instead of return to exit a subshell in dpkg-maintscript-helper.
Thanks to Richard Levitte <richard@levitte.org>. Closes: #738957
+ * Localize $_ in Perl functions with while (<$fh>) style loops.
[ Updated dpkg translations ]
* German (Sven Joachim).
@@ -301,6 +301,8 @@ $source is the origin recorded for any build flag set or modified.
sub update_from_conffile {
my ($self, $file, $src) = @_;
+ local $_;
+
return unless -e $file;
open(my $conf_fh, '<', $file) or syserr(_g('cannot read %s'), $file);
while (<$conf_fh>) {
@@ -81,6 +81,7 @@ sub parse {
my $entry = Dpkg::Changelog::Entry::Debian->new();
my @blanklines = ();
my $unknowncounter = 1; # to make version unique, e.g. for using as id
while (<$fh>) {
chomp;
@@ -102,6 +102,8 @@ sub changelog_parse {
# Extract the format from the changelog file if possible
unless($force or ($changelogfile eq '-')) {
open(my $format_fh, '-|', 'tail', '-n', '40', $changelogfile)
or syserr(_g('cannot create pipe for %s'), 'tail');
while (<$format_fh>) {
@@ -95,6 +95,8 @@ Parse options from a file handle. Return the number of options parsed.
sub parse {
my ($self, $fh, $desc) = @_;
my $count = 0;
s/^\s+//; s/\s+$//; # Strip leading/trailing spaces
@@ -186,6 +186,7 @@ sub parse {
my $parabody = 0;
my $cf; # Current field
my $expect_pgp_sig = 0;
s/\s*\n$//;
@@ -83,6 +83,8 @@ parse_ldso_conf('/etc/ld.so.conf') if -e '/etc/ld.so.conf';
my %visited;
sub parse_ldso_conf {
my $file = shift;
open my $fh, '<', $file or syserr(_g('cannot open %s'), $file);
$visited{$file}++;
@@ -93,6 +93,8 @@ sub has_object {
return $format{$file};
} else {
my ($output, %opts, $pid, $res);
if ($objdump ne 'objdump') {
$opts{error_to_file} = '/dev/null';
}
@@ -112,6 +112,8 @@ sub do_build {
my $old_cwd = getcwd();
chdir($dir) or syserr(_g("unable to chdir to `%s'"), $dir);
# Check for uncommitted files.
# To support dpkg-source -i, remove any ignored files from the
# output of bzr status.
@@ -121,7 +121,9 @@ sub do_build {
open(my $git_ls_files_fh, '-|', 'git', 'ls-files', '--modified', '--deleted',
'-z', '--others', @ignores) or subprocerr('git ls-files');
my @files;
- { local $/ = "\0";
+ {
+ local $/ = "\0";
while (<$git_ls_files_fh>) {
if (! length $diff_ignore_regex ||
@@ -107,6 +107,8 @@ sub add_diff_file {
# Check diff and write it in patch file
my $difflinefound = 0;
my $binary = 0;
while (<$diffgen>) {
if (m/^(?:binary|[^-+\@ ].*\bdiffer\b)/i) {
$binary = 1;
@@ -169,6 +169,8 @@ the filehandle in error messages.
my ($self, $fh, $varlistfile) = @_;
binmode($fh);
next if m/^\s*\#/ || !m/\S/;