* [PATCH 3/3] lei completion: workaround old Perl bug
2021-09-27 21:05 6% ` [PATCH 0/3] fixes for odd/old/missing dependencies Eric Wong
@ 2021-09-27 21:05 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-09-27 21:05 UTC (permalink / raw)
To: meta; +Cc: Konstantin Ryabitsev
While `$argv[-1]' is `undef' on an empty @argv, using `$argv[-1]'
as a subroutine argument would fail incorrectly with:
Modification of non-creatable array value attempted, subscript -1 at ...
...even though we'd never attempt to modify @_ itself in the
subroutines being called. Work around the bug (tested on
5.16.3) by passing `undef' explicitly when `$argv[-1]' is
already `undef'.
Reported-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Link: https://public-inbox.org/meta/20210927124056.kj5okiefvs4ztk27@meerkat.local/
---
lib/PublicInbox/LeiExportKw.pm | 2 +-
lib/PublicInbox/LeiImport.pm | 4 ++--
lib/PublicInbox/LeiLsMailSource.pm | 4 ++--
lib/PublicInbox/LeiRefreshMailSync.pm | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/PublicInbox/LeiExportKw.pm b/lib/PublicInbox/LeiExportKw.pm
index cea9beeb5694..0b65c2762633 100644
--- a/lib/PublicInbox/LeiExportKw.pm
+++ b/lib/PublicInbox/LeiExportKw.pm
@@ -131,7 +131,7 @@ sub _complete_export_kw {
my $match_cb = $lei->complete_url_prepare(\@argv);
# filter-out read-only sources:
my @k = grep(!m!(?://;AUTH=ANONYMOUS\@|\A(?:nntps?|s?news)://)!,
- $lms->folders($argv[-1], 1));
+ $lms->folders($argv[-1] // undef, 1));
my @m = map { $match_cb->($_) } @k;
@m ? @m : @k;
}
diff --git a/lib/PublicInbox/LeiImport.pm b/lib/PublicInbox/LeiImport.pm
index 397292d4c787..69d63ab6b397 100644
--- a/lib/PublicInbox/LeiImport.pm
+++ b/lib/PublicInbox/LeiImport.pm
@@ -122,11 +122,11 @@ sub lei_import { # the main "lei import" method
sub _complete_import {
my ($lei, @argv) = @_;
my ($re, $cur, $match_cb) = $lei->complete_url_prepare(\@argv);
- my @k = $lei->url_folder_cache->keys($argv[-1], 1);
+ my @k = $lei->url_folder_cache->keys($argv[-1] // undef, 1);
my @m = map { $match_cb->($_) } @k;
my %f = map { $_ => 1 } (@m ? @m : @k);
if (my $lms = $lei->lms) {
- @k = $lms->folders($argv[-1], 1);
+ @k = $lms->folders($argv[-1] // undef, 1);
@m = map { $match_cb->($_) } @k;
if (@m) { @f{@m} = @m } else { @f{@k} = @k }
}
diff --git a/lib/PublicInbox/LeiLsMailSource.pm b/lib/PublicInbox/LeiLsMailSource.pm
index 1db15d5742b5..7c3c0cda18d6 100644
--- a/lib/PublicInbox/LeiLsMailSource.pm
+++ b/lib/PublicInbox/LeiLsMailSource.pm
@@ -107,11 +107,11 @@ sub lei_ls_mail_source {
sub _complete_ls_mail_source {
my ($lei, @argv) = @_;
my $match_cb = $lei->complete_url_prepare(\@argv);
- my @k = $lei->url_folder_cache->keys($argv[-1], 1);
+ my @k = $lei->url_folder_cache->keys($argv[-1] // undef, 1);
my @m = map { $match_cb->($_) } @k;
my %f = map { $_ => 1 } (@m ? @m : @k);
if (my $lms = $lei->lms) {
- @k = $lms->folders($argv[-1], 1);
+ @k = $lms->folders($argv[-1] // undef, 1);
@m = map { $match_cb->($_) } grep(m!\A[a-z]+://!, @k);
if (@m) { @f{@m} = @m } else { @f{@k} = @k }
}
diff --git a/lib/PublicInbox/LeiRefreshMailSync.pm b/lib/PublicInbox/LeiRefreshMailSync.pm
index eb842843b51d..0cb9f3dccd48 100644
--- a/lib/PublicInbox/LeiRefreshMailSync.pm
+++ b/lib/PublicInbox/LeiRefreshMailSync.pm
@@ -101,7 +101,7 @@ sub _complete_refresh_mail_sync {
my ($lei, @argv) = @_;
my $lms = $lei->lms or return ();
my $match_cb = $lei->complete_url_prepare(\@argv);
- my @k = $lms->folders($argv[-1], 1);
+ my @k = $lms->folders($argv[-1] // undef, 1);
my @m = map { $match_cb->($_) } @k;
@m ? @m : @k
}
^ permalink raw reply related [relevance 7%]
* [PATCH 0/3] fixes for odd/old/missing dependencies
@ 2021-09-27 21:05 6% ` Eric Wong
2021-09-27 21:05 7% ` [PATCH 3/3] lei completion: workaround old Perl bug Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-09-27 21:05 UTC (permalink / raw)
To: meta, Konstantin Ryabitsev
On Mon, 27 Sep 2021 15:45:20 -0400, Konstantin Ryabitsev wrote:
> On Mon, Sep 27, 2021 at 07:33:46PM +0000, Eric Wong wrote:
> > The partial fetching would need some work to support working as
> > root.
>
> Ah. Just catch this with check if if id=0 and skipping the test as "known not
> to work for this use-case."
It wasn't much to add support for root, actually. The rest of
the stuff should be fixed, too.
Eric Wong (3):
fetch: support running as root
t/lei-index: IMAP and NNTP dependencies are optional
lei completion: workaround old Perl bug
lib/PublicInbox/Fetch.pm | 15 ++++++++++--
lib/PublicInbox/LeiExportKw.pm | 2 +-
lib/PublicInbox/LeiImport.pm | 4 +--
lib/PublicInbox/LeiLsMailSource.pm | 4 +--
lib/PublicInbox/LeiRefreshMailSync.pm | 2 +-
t/lei-index.t | 35 ++++++++++++++++++---------
t/v2mirror.t | 13 +++++++---
7 files changed, 52 insertions(+), 23 deletions(-)
^ permalink raw reply [relevance 6%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-09-27 19:45 -fetch failures [was: latest make test failures on CentOS-7] Konstantin Ryabitsev
2021-09-27 21:05 6% ` [PATCH 0/3] fixes for odd/old/missing dependencies Eric Wong
2021-09-27 21:05 7% ` [PATCH 3/3] lei completion: workaround old Perl bug Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).