From: Eric Wong Date: Tue, 23 Aug 2022 08:32:02 +0000 (+0000) Subject: gzip_filter: ->zmore and ->zflush support multiple args X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=5e72c9aacf7e98e97d5a0f266580c187129ed86f;p=public-inbox.git gzip_filter: ->zmore and ->zflush support multiple args This will make writev-like use easier for the next commit, and also future changes where I'll rely more on zlib for buffering. --- diff --git a/lib/PublicInbox/GzipFilter.pm b/lib/PublicInbox/GzipFilter.pm index bdd313f5..86d34183 100644 --- a/lib/PublicInbox/GzipFilter.pm +++ b/lib/PublicInbox/GzipFilter.pm @@ -139,19 +139,22 @@ sub write { sub zmore { my $self = $_[0]; # $_[1] => input http_out($self); - my $err = $self->{gz}->deflate($_[1], $self->{zbuf}); - die "gzip->deflate: $err" if $err != Z_OK; + my $err; + for (1..$#_) { + $err = $self->{gz}->deflate($_[$_], $self->{zbuf}); + die "gzip->deflate: $err" if $err != Z_OK; + } undef; } # flushes and returns the final bit of gzipped data -sub zflush ($;$) { - my $self = $_[0]; # $_[1] => final input (optional) +sub zflush ($;@) { + my $self = $_[0]; # $_[1..Inf] => final input (optional) my $zbuf = delete $self->{zbuf}; my $gz = delete $self->{gz}; my $err; - if (defined $_[1]) { # it's a bug iff $gz is undef w/ $_[1] - $err = $gz->deflate($_[1], $zbuf); + for (1..$#_) { # it's a bug iff $gz is undef w/ $_[1..] + $err = $gz->deflate($_[$_], $zbuf); die "gzip->deflate: $err" if $err != Z_OK; } $gz // return ''; # not a bug, recursing on DS->write failure