diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2015-09-10 03:38:40 +0200 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2015-09-10 03:41:05 +0200 |
commit | 5e127a1b56879ee24bcdf56c9c1eeb4f7dac4bc4 (patch) | |
tree | f9d73d35db5dfe2e072e0465853bb80a9a0d4ba1 /lib/Net | |
parent | 5104962fbe1d9c9b602cdd4e4d9fb4d19f4f9b8c (diff) |
wibble
Diffstat (limited to 'lib/Net')
-rw-r--r-- | lib/Net/IMAP/InterIMAP.pm | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/lib/Net/IMAP/InterIMAP.pm b/lib/Net/IMAP/InterIMAP.pm index 3b9e10e..ee8677a 100644 --- a/lib/Net/IMAP/InterIMAP.pm +++ b/lib/Net/IMAP/InterIMAP.pm @@ -20,7 +20,7 @@ package Net::IMAP::InterIMAP v0.0.2; use warnings; use strict; -use Compress::Zlib qw/Z_OK Z_FULL_FLUSH Z_SYNC_FLUSH MAX_WBITS/; +use Compress::Zlib qw/Z_FULL_FLUSH Z_SYNC_FLUSH MAX_WBITS/; use Config::Tiny (); use Errno 'EWOULDBLOCK'; use IO::Select (); @@ -425,16 +425,11 @@ sub new($%) { $self->panic($IMAP_text) unless $r eq 'OK'; if ($algo eq 'DEFLATE') { - my ($status, $d, $i); my %args = ( -WindowBits => 0 - MAX_WBITS ); - ($d, $status) = Compress::Zlib::deflateInit(%args); - $self->panic("Can't create deflation stream: ", $d->msg()) - unless defined $d and $status == Z_OK; - - ($i, $status) = Compress::Zlib::inflateInit(%args); - $self->panic("Can't create inflation stream: ", $i->msg()) - unless defined $i and $status == Z_OK; - @$self{qw/_Z_DEFLATE _Z_INFLATE/} = ($d, $i); + $self->{_Z_DEFLATE} = Compress::Zlib::deflateInit(%args) // + $self->panic("Can't create deflation stream"); + $self->{_Z_INFLATE} = Compress::Zlib::inflateInit(%args) // + $self->panic("Can't create inflation stream"); } else { $self->fail("Unsupported compression algorithm: $algo"); @@ -1254,9 +1249,7 @@ sub _getline($;$) { $self->{_OUTRAWCOUNT} += $n; if (defined (my $i = $self->{_Z_INFLATE})) { - my ($out, $status) = $i->inflate($buf); - $self->panic("Inflation failed: ", $i->msg()) unless $status == Z_OK; - $buf = $out; + $buf = $i->inflate($buf) // $self->panic("Inflation failed: ", $i->msg()); } $self->{_OUTBUF} = $buf; } @@ -1345,9 +1338,7 @@ sub _write($@) { sub _z_flush($;$) { my ($self,$t) = @_; my $d = $self->{_Z_DEFLATE} // return; - my ($out, $status) = $d->flush($t); - $self->panic("Can't flush deflation stream: ", $d->msg()) unless $status == Z_OK; - $self->_write($out); + $self->_write( $d->flush($t) // $self->panic("Can't flush deflation stream: ", $d->msg()) ); } @@ -1393,11 +1384,7 @@ sub _send_cmd($) { else { for (my $i = 0; $i <= $#data; $i++) { $self->_z_flush(Z_FULL_FLUSH) if $i == 0 and $z_flush; - - my ($out, $status) = $d->deflate($data[$i]); - $self->panic("Deflation failed: ", $d->msg()) unless $status == Z_OK; - $self->_write($out); - + $self->_write( $d->deflate($data[$i]) // $self->panic("Deflation failed: ", $d->msg()) ); $self->_z_flush(Z_FULL_FLUSH) if $i == 0 and $z_flush; } } |