From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH] substr
Date: Fri, 19 Apr 2024 08:47:29 +0000 [thread overview]
Message-ID: <20240419084729.1788274-1-e@80x24.org> (raw)
---
lib/PublicInbox/HTTP.pm | 6 +++---
lib/PublicInbox/IMAP.pm | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm
index 7162732e..d3d142dd 100644
--- a/lib/PublicInbox/HTTP.pm
+++ b/lib/PublicInbox/HTTP.pm
@@ -98,7 +98,7 @@ sub event_step { # called by PublicInbox::DS
$self->do_read($rbuf, 8192, length($$rbuf)) or return;
}
return quit($self, 400) if grep(/\s/, keys %env); # stop smugglers
- $$rbuf = substr($$rbuf, $r);
+ substr($$rbuf, 0, $r, '');
my $len = input_prepare($self, \%env) //
return write_err($self, undef); # EMFILE/ENFILE
@@ -122,7 +122,7 @@ sub read_input ($;$) {
$len -= $w;
die "BUG: $len < 0 (w=$w)" if $len < 0;
if ($len == 0) { # next request may be pipelined
- $$rbuf = substr($$rbuf, $w);
+ substr($$rbuf, 0, $w, '');
last;
}
$$rbuf = '';
@@ -404,7 +404,7 @@ sub read_input_chunked { # unlikely...
if ($len == 0) {
# we may have leftover data to parse
# in chunk
- $$rbuf = substr($$rbuf, $w);
+ substr($$rbuf, 0, $w, '');
$len = CHUNK_END;
} elsif ($len < 0) {
die "BUG: len < 0: $len";
diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm
index b12533cb..ff62767e 100644
--- a/lib/PublicInbox/IMAP.pm
+++ b/lib/PublicInbox/IMAP.pm
@@ -964,7 +964,7 @@ sub partial_emit ($$$) {
$k =~ s/\.$len>\z/>/ or warn
"BUG: unable to remove `.$len>' from `$k'";
} else {
- $str = substr($str, $offset);
+ substr($str, 0, $offset, '');
$len = length($str);
}
} else {
reply other threads:[~2024-04-19 8:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240419084729.1788274-1-e@80x24.org \
--to=e@80x24.org \
--cc=spew@80x24.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.
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).