dumping ground for random patches and texts
 help / color / mirror / Atom feed
* [PATCH] substr
@ 2024-04-19  8:47 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2024-04-19  8:47 UTC (permalink / raw)
  To: spew

---
 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 {

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-19  8:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-19  8:47 [PATCH] substr Eric Wong

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).