From 57b18b44e1770b163aba55eacf53195a8305398e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 21 May 2016 05:27:06 +0000 Subject: localize $/ in more places to avoid potential problems This hopefully makes the intent of the code clearer, too. The the HTTP use of the numeric reference for getline caused problems in Git.pm, already. --- lib/PublicInbox/Config.pm | 1 + lib/PublicInbox/Daemon.pm | 1 + lib/PublicInbox/Feed.pm | 2 ++ lib/PublicInbox/Git.pm | 1 + lib/PublicInbox/SearchIdx.pm | 2 ++ 5 files changed, 7 insertions(+) (limited to 'lib') diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm index b5f0fcb1..b38f4443 100644 --- a/lib/PublicInbox/Config.pm +++ b/lib/PublicInbox/Config.pm @@ -80,6 +80,7 @@ sub git_config_dump { my $pid = open(my $fh, '-|', @cmd); defined $pid or die "$cmd failed: $!"; my %rv; + local $/ = "\n"; foreach my $line (<$fh>) { chomp $line; my ($k, $v) = split(/=/, $line, 2); diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm index 8de7ff24..dc810106 100644 --- a/lib/PublicInbox/Daemon.pm +++ b/lib/PublicInbox/Daemon.pm @@ -350,6 +350,7 @@ sub unlink_pid_file_safe_ish ($$) { return unless defined $unlink_pid && $unlink_pid == $$; open my $fh, '<', $file or return; + local $/ = "\n"; defined(my $read_pid = <$fh>) or return; chomp $read_pid; if ($read_pid == $unlink_pid) { diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm index e2df97b1..6ed00856 100644 --- a/lib/PublicInbox/Feed.pm +++ b/lib/PublicInbox/Feed.pm @@ -224,6 +224,7 @@ sub each_recent_blob { my $nr = 0; my ($cur_commit, $first_commit, $last_commit); my ($ts, $subj, $u); + local $/ = "\n"; while (defined(my $line = <$log>)) { if ($line =~ /$addmsg/o) { my $add = $1; @@ -244,6 +245,7 @@ sub each_recent_blob { } if ($last) { + local $/ = "\n"; while (my $line = <$log>) { if ($line =~ /^(${hex}{7,40})/o) { $last_commit = $1; diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index 473cdffa..bc0e5064 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -122,6 +122,7 @@ sub popen { sub qx { my ($self, @cmd) = @_; my $fh = $self->popen(@cmd); + local $/ = "\n"; return <$fh> if wantarray; local $/; <$fh> diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index 9192bb07..4a4b2bdb 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -338,6 +338,7 @@ sub rlog { --raw -r --no-abbrev/, $range); my $latest; my $bytes; + local $/ = "\n"; while (defined(my $line = <$log>)) { if ($line =~ /$addmsg/o) { my $mime = do_cat_mail($git, $1, \$bytes) or next; @@ -445,6 +446,7 @@ sub _read_git_config_perm { my ($self) = @_; my @cmd = qw(config core.sharedRepository); my $fh = PublicInbox::Git->new($self->{git_dir})->popen(@cmd); + local $/ = "\n"; my $perm = <$fh>; chomp $perm if defined $perm; $perm; -- cgit v1.2.3-24-ge0c7