about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiInspect.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/LeiInspect.pm')
-rw-r--r--lib/PublicInbox/LeiInspect.pm27
1 files changed, 8 insertions, 19 deletions
diff --git a/lib/PublicInbox/LeiInspect.pm b/lib/PublicInbox/LeiInspect.pm
index d1dca4ef..576ab2c7 100644
--- a/lib/PublicInbox/LeiInspect.pm
+++ b/lib/PublicInbox/LeiInspect.pm
@@ -12,7 +12,6 @@ use parent qw(PublicInbox::IPC);
 use PublicInbox::Config;
 use PublicInbox::MID qw(mids);
 use PublicInbox::NetReader qw(imap_uri nntp_uri);
-use POSIX qw(strftime);
 use PublicInbox::LeiOverview;
 *iso8601 = \&PublicInbox::LeiOverview::iso8601;
 
@@ -97,7 +96,6 @@ sub _inspect_doc ($$) {
                 my $term = ($1 // '');
                 push @{$ent->{terms}->{$term}}, $tn;
         }
-        @$_ = sort(@$_) for values %{$ent->{terms} // {}};
         $cur = $doc->values_begin;
         $end = $doc->values_end;
         for (; $cur != $end; $cur++) {
@@ -251,21 +249,13 @@ sub inspect_start ($$) {
         $self->wq_close;
 }
 
-sub ins_add { # InputPipe->consume callback
-        my ($lei) = @_; # $_[1] = $rbuf
-        if (defined $_[1]) {
-                $_[1] eq '' and return eval {
-                        my $str = delete $lei->{istr};
-                        $str =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s;
-                        my $eml = PublicInbox::Eml->new(\$str);
-                        inspect_start($lei, [
-                                'blob:'.$lei->git_oid($eml)->hexdigest,
-                                map { "mid:$_" } @{mids($eml)} ]);
-                };
-                $lei->{istr} .= $_[1];
-        } else {
-                $lei->fail("error reading stdin: $!");
-        }
+sub do_inspect { # lei->do_env cb
+        my ($lei) = @_;
+        my $str = delete $lei->{stdin_buf};
+        PublicInbox::Eml::strip_from($str);
+        my $eml = PublicInbox::Eml->new(\$str);
+        inspect_start($lei, [ 'blob:'.$lei->git_oid($eml)->hexdigest,
+                        map { "mid:$_" } @{mids($eml)} ]);
 }
 
 sub lei_inspect {
@@ -282,8 +272,7 @@ sub lei_inspect {
                 return $lei->fail(<<'') if @argv;
 no args allowed on command-line with --stdin
 
-                require PublicInbox::InputPipe;
-                PublicInbox::InputPipe::consume($lei->{0}, \&ins_add, $lei);
+                $lei->slurp_stdin(\&do_inspect);
         } else {
                 inspect_start($lei, \@argv);
         }