diff options
author | Eric Wong <e@80x24.org> | 2022-08-23 08:32:02 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2022-08-23 22:40:57 +0000 |
commit | 5e72c9aacf7e98e97d5a0f266580c187129ed86f (patch) | |
tree | 85e21302419e0c1af7a0a8d0ea24bacc49a60144 /lib | |
parent | 31d40ba06a49b572dacbdb5758dac8f77fb55188 (diff) | |
download | public-inbox-5e72c9aacf7e98e97d5a0f266580c187129ed86f.tar.gz |
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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/PublicInbox/GzipFilter.pm | 15 |
1 files changed, 9 insertions, 6 deletions
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 |