From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id EB4611F61F for ; Tue, 23 Aug 2022 08:32:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1661243524; bh=yxOq5yOmTZJWcrrqnJ6xObXGpu1LFEEcWMwcCJ4Ys/k=; h=From:To:Subject:Date:In-Reply-To:References:From; b=idKatc5hqwcVy99mNA8tmKXCl1P+wkqXaUv1+XFbtDGuoQBC26hq7PxhKffVhIMis j3c3SRK1R5KI4868RTr/LoeUNJNRbOYJeyz4sUCgLluUOytGw2vltOe1eEb9emjhv8 wtRpx5BJYEpIbnoWiD4rfsAxARzZqiJyOCygmdFU= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 7/8] gzip_filter: ->zmore and ->zflush support multiple args Date: Tue, 23 Aug 2022 08:32:02 +0000 Message-Id: <20220823083203.1128993-8-e@80x24.org> In-Reply-To: <20220823083203.1128993-1-e@80x24.org> References: <20220823083203.1128993-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This will make writev-like use easier for the next commit, and also future changes where I'll rely more on zlib for buffering. --- lib/PublicInbox/GzipFilter.pm | 15 +++++++++------ 1 file 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