From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 3/8] nntp: hdr_searchmsg: use named sub for numeric range response
Date: Sat, 21 Dec 2019 08:00:02 +0000 [thread overview]
Message-ID: <20191221080007.27810-4-e@80x24.org> (raw)
In-Reply-To: <20191221080007.27810-1-e@80x24.org>
Introduce searchmsg_range_i, which does the same thing as
the anonymous sub it replaces.
---
lib/PublicInbox/NNTP.pm | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index 33c557f5..30862dca 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -727,6 +727,20 @@ sub over_header_for {
$smsg->{$field};
}
+sub searchmsg_range_i {
+ my ($self, $beg, $end, $field) = @_;
+ my $over = $self->{ng}->over;
+ my $msgs = $over->query_xover($$beg, $end);
+ scalar(@$msgs) or return;
+ my $tmp = '';
+ foreach my $s (@$msgs) {
+ $tmp .= $s->{num} . ' ' . $s->$field . "\r\n";
+ }
+ utf8::encode($tmp);
+ $self->msg_more($tmp);
+ $$beg = $msgs->[-1]->{num} + 1;
+}
+
sub hdr_searchmsg ($$$$) {
my ($self, $xhdr, $field, $range) = @_;
if (defined $range && $range =~ /\A<(.+)>\z/) { # Message-ID
@@ -736,24 +750,10 @@ sub hdr_searchmsg ($$$$) {
hdr_mid_response($self, $xhdr, $ng, $n, $range, $v);
} else { # numeric range
$range = $self->{article} unless defined $range;
- my $over = $self->{ng}->over;
- my $mm = $self->{ng}->mm;
my $r = get_range($self, $range);
return $r unless ref $r;
- my ($beg, $end) = @$r;
more($self, $xhdr ? r221 : r225);
- my $cur = $$beg;
- long_response($self, sub {
- my $msgs = $over->query_xover($cur, $end);
- my $nr = scalar @$msgs or return;
- my $tmp = '';
- foreach my $s (@$msgs) {
- $tmp .= $s->{num} . ' ' . $s->$field . "\r\n";
- }
- utf8::encode($tmp);
- $self->msg_more($tmp);
- $cur = $msgs->[-1]->{num} + 1;
- });
+ long_response($self, \&searchmsg_range_i, @$r, $field);
}
}
next prev parent reply other threads:[~2019-12-21 8:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-21 7:59 [PATCH 0/8] nntp: eliminate response-duration cyclic refs Eric Wong
2019-12-21 8:00 ` [PATCH 1/8] nntp: get_range: return scalarref for $beg Eric Wong
2019-12-21 8:00 ` [PATCH 2/8] nntp: remove cyclic refs from long_response Eric Wong
2019-12-21 8:00 ` Eric Wong [this message]
2019-12-21 8:00 ` [PATCH 4/8] nntp: cmd_xrover: use named sub for long_response Eric Wong
2019-12-21 8:00 ` [PATCH 5/8] nntp: cmd_listgroup: use named subs " Eric Wong
2019-12-21 8:00 ` [PATCH 6/8] nntp: cmd_newnews: use named sub " Eric Wong
2019-12-21 8:00 ` [PATCH 7/8] nntp: hdr_msg_id: " Eric Wong
2019-12-21 8:00 ` [PATCH 8/8] nntp: cmd_xover: " Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191221080007.27810-4-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).