about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiLcat.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-10-17 10:11:04 +0000
committerEric Wong <e@80x24.org>2023-10-17 20:30:05 +0000
commitcb1c4976f116ebdf94300fd474c7176e82122003 (patch)
tree405e044a4d2397acd24aedfd6f0d28bd51124a72 /lib/PublicInbox/LeiLcat.pm
parente740838a3854a45e51d8ae089a90f08c076190bd (diff)
downloadpublic-inbox-cb1c4976f116ebdf94300fd474c7176e82122003.tar.gz
We can share more code amongst stdin slurper (not streaming)
commands.  This also fixes uninitialized variable warnings when
feeding an empty stdin to these commands.
Diffstat (limited to 'lib/PublicInbox/LeiLcat.pm')
-rw-r--r--lib/PublicInbox/LeiLcat.pm13
1 files changed, 2 insertions, 11 deletions
diff --git a/lib/PublicInbox/LeiLcat.pm b/lib/PublicInbox/LeiLcat.pm
index 72875dc6..274a9605 100644
--- a/lib/PublicInbox/LeiLcat.pm
+++ b/lib/PublicInbox/LeiLcat.pm
@@ -124,18 +124,11 @@ could not extract Message-ID from $x
 
 sub do_lcat { # lei->do_env cb
         my ($lei) = @_;
-        my @argv = split(/\s+/, $lei->{mset_opt}->{qstr});
+        my @argv = split(/\s+/, delete($lei->{stdin_buf}));
         $lei->{mset_opt}->{qstr} = extract_all($lei, @argv) or return;
         $lei->_start_query;
 }
 
-sub _stdin { # PublicInbox::InputPipe::consume callback for --stdin
-        my ($lei) = @_; # $_[1] = $rbuf
-        $_[1] // return $lei->fail("error reading stdin: $!");
-        return $lei->{mset_opt}->{qstr} .= $_[1] if $_[1] ne '';
-        $lei->do_env(\&do_lcat);
-}
-
 sub lei_lcat {
         my ($lei, @argv) = @_;
         my $lxs = $lei->lxs_prepare or return;
@@ -152,9 +145,7 @@ sub lei_lcat {
                 return $lei->fail(<<'') if @argv;
 no args allowed on command-line with --stdin
 
-                require PublicInbox::InputPipe;
-                PublicInbox::InputPipe::consume($lei->{0}, \&_stdin, $lei);
-                return;
+                return $lei->slurp_stdin(\&do_lcat);
         }
         $lei->{mset_opt}->{qstr} = extract_all($lei, @argv) or return;
         $lei->_start_query;