From: Eric Wong Date: Mon, 22 Nov 2021 18:23:52 +0000 (+0000) Subject: searchidx: avoid modification of read-only `$_' X-Git-Tag: v1.8.0~41 X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=commitdiff_plain;h=eee1eb1ed3bbf3264676954bb879ed67376169b6 searchidx: avoid modification of read-only `$_' This fixes the "Modification of a read-only value attempted at ..." error in an initial run of t/reindex-time-range.t. It was reproducible by running `rm -rf t/data-gen/reindex-time-range.v*' before `make && prove -bvw t/reindex-time-range.t'. Thanks to Jörg Rödel for providing the backtrace which helped find this. Debugged-by: Jörg Rödel Link: https://public-inbox.org/meta/YZuZEY+WSnm4wlrS@8bytes.org/ --- diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index 6e2e614c..4e5d7d44 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -896,20 +896,20 @@ sub log2stack ($$$) { push @cmd, "--$k=$v"; } my $fh = $git->popen(@cmd, $range); - my ($at, $ct, $stk, $cmt); - while (<$fh>) { + my ($at, $ct, $stk, $cmt, $l); + while (defined($l = <$fh>)) { return if $sync->{quit}; - if (/\A([0-9]+)-([0-9]+)-($OID)$/o) { + if ($l =~ /\A([0-9]+)-([0-9]+)-($OID)$/o) { ($at, $ct, $cmt) = ($1 + 0, $2 + 0, $3); $stk //= PublicInbox::IdxStack->new($cmt); - } elsif (/$del/) { + } elsif ($l =~ /$del/) { my $oid = $1; if ($D) { # reindex case $D->{pack('H*', $oid)}++; } else { # non-reindex case: $stk->push_rec('d', $at, $ct, $oid, $cmt); } - } elsif (/$add/) { + } elsif ($l =~ /$add/) { my $oid = $1; if ($D) { my $oid_bin = pack('H*', $oid);