update boost
This commit is contained in:
@@ -91,6 +91,16 @@ public:
|
||||
after a reset, any required internal buffers are not
|
||||
dynamically allocated until needed.
|
||||
|
||||
@param level Compression level from 0 to 9.
|
||||
|
||||
@param windowBits The base two logarithm of the window size, or the
|
||||
history buffer. It should be in the range 9..15.
|
||||
|
||||
@param memLevel How much memory should be allocated for the internal
|
||||
compression state, with level from from 1 to 9.
|
||||
|
||||
@param strategy Strategy to tune the compression algorithm.
|
||||
|
||||
@note Any unprocessed input or pending output from
|
||||
previous calls are discarded.
|
||||
*/
|
||||
@@ -364,6 +374,8 @@ public:
|
||||
of bytes needed to store the result of compressing a block of
|
||||
data.
|
||||
|
||||
|
||||
|
||||
@param bytes The size of the uncompressed data.
|
||||
|
||||
@return The maximum number of resulting compressed bytes.
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
//
|
||||
// This is a derivative work based on Zlib, copyright below:
|
||||
/*
|
||||
Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
|
||||
Copyright (C) 1995-2018 Jean-loup Gailly and Mark Adler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -40,7 +40,6 @@
|
||||
#include <boost/beast/zlib/error.hpp>
|
||||
#include <boost/beast/zlib/zlib.hpp>
|
||||
#include <boost/beast/zlib/detail/ranges.hpp>
|
||||
#include <boost/beast/core/detail/type_traits.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
@@ -371,7 +370,7 @@ protected:
|
||||
// Depth of each subtree used as tie breaker for trees of equal frequency
|
||||
std::uint8_t depth_[2*lCodes+1];
|
||||
|
||||
std::uint8_t *l_buf_; // buffer for literals or lengths
|
||||
std::uint8_t *sym_buf_; // buffer for distances and literals or lengths
|
||||
|
||||
/* Size of match buffer for literals/lengths.
|
||||
There are 4 reasons for limiting lit_bufsize to 64K:
|
||||
@@ -392,13 +391,9 @@ protected:
|
||||
- I can't count above 4
|
||||
*/
|
||||
uInt lit_bufsize_;
|
||||
uInt last_lit_; // running index in l_buf_
|
||||
|
||||
/* Buffer for distances. To simplify the code, d_buf_ and l_buf_
|
||||
have the same number of elements. To use different lengths, an
|
||||
extra flag array would be necessary.
|
||||
*/
|
||||
std::uint16_t* d_buf_;
|
||||
uInt sym_next_; /* running index in sym_buf */
|
||||
uInt sym_end_; /* symbol table full when sym_next reaches this */
|
||||
|
||||
std::uint32_t opt_len_; // bit length of current block with optimal trees
|
||||
std::uint32_t static_len_; // bit length of current block with static trees
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
//
|
||||
// This is a derivative work based on Zlib, copyright below:
|
||||
/*
|
||||
Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
|
||||
Copyright (C) 1995-2018 Jean-loup Gailly and Mark Adler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -39,7 +39,6 @@
|
||||
|
||||
#include <boost/beast/zlib/detail/deflate_stream.hpp>
|
||||
#include <boost/beast/zlib/detail/ranges.hpp>
|
||||
#include <boost/beast/core/detail/type_traits.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/make_unique.hpp>
|
||||
@@ -327,7 +326,7 @@ doParams(z_params& zs, int level, Strategy strategy, error_code& ec)
|
||||
level = 6;
|
||||
if(level < 0 || level > 9)
|
||||
{
|
||||
ec = error::stream_error;
|
||||
BOOST_BEAST_ASSIGN_EC(ec, error::stream_error);
|
||||
return;
|
||||
}
|
||||
func = get_config(level_).func;
|
||||
@@ -361,15 +360,18 @@ doWrite(z_params& zs, boost::optional<Flush> flush, error_code& ec)
|
||||
{
|
||||
maybe_init();
|
||||
|
||||
if(zs.next_out == 0 || (zs.next_in == 0 && zs.avail_in != 0) ||
|
||||
if(zs.next_in == nullptr && zs.avail_in != 0)
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument{"invalid input"});
|
||||
|
||||
if(zs.next_out == nullptr ||
|
||||
(status_ == FINISH_STATE && flush != Flush::finish))
|
||||
{
|
||||
ec = error::stream_error;
|
||||
BOOST_BEAST_ASSIGN_EC(ec, error::stream_error);
|
||||
return;
|
||||
}
|
||||
if(zs.avail_out == 0)
|
||||
{
|
||||
ec = error::need_buffers;
|
||||
BOOST_BEAST_ASSIGN_EC(ec, error::need_buffers);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -397,21 +399,21 @@ doWrite(z_params& zs, boost::optional<Flush> flush, error_code& ec)
|
||||
}
|
||||
}
|
||||
else if(zs.avail_in == 0 && (
|
||||
old_flush && flush <= *old_flush
|
||||
old_flush && flush <= *old_flush // Caution: depends on enum order
|
||||
) && flush != Flush::finish)
|
||||
{
|
||||
/* Make sure there is something to do and avoid duplicate consecutive
|
||||
* flushes. For repeated and useless calls with Flush::finish, we keep
|
||||
* returning Z_STREAM_END instead of Z_BUF_ERROR.
|
||||
*/
|
||||
ec = error::need_buffers;
|
||||
BOOST_BEAST_ASSIGN_EC(ec, error::need_buffers);
|
||||
return;
|
||||
}
|
||||
|
||||
// User must not provide more input after the first FINISH:
|
||||
if(status_ == FINISH_STATE && zs.avail_in != 0)
|
||||
{
|
||||
ec = error::need_buffers;
|
||||
BOOST_BEAST_ASSIGN_EC(ec, error::need_buffers);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -465,7 +467,7 @@ doWrite(z_params& zs, boost::optional<Flush> flush, error_code& ec)
|
||||
else if(flush != Flush::block)
|
||||
{
|
||||
/* FULL_FLUSH or SYNC_FLUSH */
|
||||
tr_stored_block((char*)0, 0L, 0);
|
||||
tr_stored_block(nullptr, 0L, 0);
|
||||
/* For a full flush, this empty block will be recognized
|
||||
* as a special marker by inflate_sync().
|
||||
*/
|
||||
@@ -491,7 +493,7 @@ doWrite(z_params& zs, boost::optional<Flush> flush, error_code& ec)
|
||||
|
||||
if(flush == Flush::finish)
|
||||
{
|
||||
ec = error::end_of_stream;
|
||||
BOOST_BEAST_ASSIGN_EC(ec, error::end_of_stream);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -503,7 +505,7 @@ doDictionary(Byte const* dict, uInt dictLength, error_code& ec)
|
||||
{
|
||||
if(lookahead_)
|
||||
{
|
||||
ec = error::stream_error;
|
||||
BOOST_BEAST_ASSIGN_EC(ec, error::stream_error);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -557,9 +559,9 @@ doPrime(int bits, int value, error_code& ec)
|
||||
{
|
||||
maybe_init();
|
||||
|
||||
if((Byte *)(d_buf_) < pending_out_ + ((Buf_size + 7) >> 3))
|
||||
if((Byte *)(sym_buf_) < pending_out_ + ((Buf_size + 7) >> 3))
|
||||
{
|
||||
ec = error::need_buffers;
|
||||
BOOST_BEAST_ASSIGN_EC(ec, error::need_buffers);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -623,26 +625,58 @@ init()
|
||||
|
||||
window_ = reinterpret_cast<Byte*>(buf_.get());
|
||||
prev_ = reinterpret_cast<std::uint16_t*>(buf_.get() + nwindow);
|
||||
std::memset(prev_, 0, nprev);
|
||||
head_ = reinterpret_cast<std::uint16_t*>(buf_.get() + nwindow + nprev);
|
||||
|
||||
/* We overlay pending_buf_ and d_buf_ + l_buf_. This works
|
||||
since the average output size for(length, distance)
|
||||
codes is <= 24 bits.
|
||||
*/
|
||||
auto overlay = reinterpret_cast<std::uint16_t*>(
|
||||
buf_.get() + nwindow + nprev + nhead);
|
||||
|
||||
// nothing written to window_ yet
|
||||
high_water_ = 0;
|
||||
|
||||
pending_buf_ =
|
||||
reinterpret_cast<std::uint8_t*>(overlay);
|
||||
pending_buf_size_ =
|
||||
static_cast<std::uint32_t>(lit_bufsize_) *
|
||||
(sizeof(std::uint16_t) + 2L);
|
||||
|
||||
d_buf_ = overlay + lit_bufsize_ / sizeof(std::uint16_t);
|
||||
l_buf_ = pending_buf_ + (1 + sizeof(std::uint16_t)) * lit_bufsize_;
|
||||
/* We overlay pending_buf and sym_buf. This works since the average size
|
||||
for length/distance pairs over any compressed block is assured to be 31
|
||||
bits or less.
|
||||
|
||||
Analysis: The longest fixed codes are a length code of 8 bits plus 5
|
||||
extra bits, for lengths 131 to 257. The longest fixed distance codes are
|
||||
5 bits plus 13 extra bits, for distances 16385 to 32768. The longest
|
||||
possible fixed-codes length/distance pair is then 31 bits total.
|
||||
|
||||
sym_buf starts one-fourth of the way into pending_buf. So there are
|
||||
three bytes in sym_buf for every four bytes in pending_buf. Each symbol
|
||||
in sym_buf is three bytes -- two for the distance and one for the
|
||||
literal/length. As each symbol is consumed, the pointer to the next
|
||||
sym_buf value to read moves forward three bytes. From that symbol, up to
|
||||
31 bits are written to pending_buf. The closest the written pending_buf
|
||||
bits gets to the next sym_buf symbol to read is just before the last
|
||||
code is written. At that time, 31*(n-2) bits have been written, just
|
||||
after 24*(n-2) bits have been consumed from sym_buf. sym_buf starts at
|
||||
8*n bits into pending_buf. (Note that the symbol buffer fills when n-1
|
||||
symbols are written.) The closest the writing gets to what is unread is
|
||||
then n+14 bits. Here n is lit_bufsize, which is 16384 by default, and
|
||||
can range from 128 to 32768.
|
||||
|
||||
Therefore, at a minimum, there are 142 bits of space between what is
|
||||
written and what is read in the overlain buffers, so the symbols cannot
|
||||
be overwritten by the compressed data. That space is actually 139 bits,
|
||||
due to the three-bit fixed-code block header.
|
||||
|
||||
That covers the case where either Z_FIXED is specified, forcing fixed
|
||||
codes, or when the use of fixed codes is chosen, because that choice
|
||||
results in a smaller compressed block than dynamic codes. That latter
|
||||
condition then assures that the above analysis also covers all dynamic
|
||||
blocks. A dynamic-code block will only be chosen to be emitted if it has
|
||||
fewer bits than a fixed-code block would for the same set of symbols.
|
||||
Therefore its average symbol length is assured to be less than 31. So
|
||||
the compressed data for a dynamic block also cannot overwrite the
|
||||
symbols from which it is being constructed.
|
||||
*/
|
||||
pending_buf_ =
|
||||
buf_.get() + nwindow + nprev + nhead;
|
||||
pending_buf_size_ =
|
||||
static_cast<std::uint32_t>(lit_bufsize_) * 4;
|
||||
|
||||
sym_buf_ = pending_buf_ + lit_bufsize_;
|
||||
sym_end_ = (lit_bufsize_ - 1) * 3;
|
||||
|
||||
pending_ = 0;
|
||||
pending_out_ = pending_buf_;
|
||||
@@ -698,7 +732,7 @@ init_block()
|
||||
dyn_ltree_[END_BLOCK].fc = 1;
|
||||
opt_len_ = 0L;
|
||||
static_len_ = 0L;
|
||||
last_lit_ = 0;
|
||||
sym_next_ = 0;
|
||||
matches_ = 0;
|
||||
}
|
||||
|
||||
@@ -1155,16 +1189,17 @@ compress_block(
|
||||
{
|
||||
unsigned dist; /* distance of matched string */
|
||||
int lc; /* match length or unmatched char (if dist == 0) */
|
||||
unsigned lx = 0; /* running index in l_buf */
|
||||
unsigned sx = 0; /* running index in sym_buf */
|
||||
unsigned code; /* the code to send */
|
||||
int extra; /* number of extra bits to send */
|
||||
|
||||
if(last_lit_ != 0)
|
||||
if(sym_next_ != 0)
|
||||
{
|
||||
do
|
||||
{
|
||||
dist = d_buf_[lx];
|
||||
lc = l_buf_[lx++];
|
||||
dist = sym_buf_[sx++] & 0xff;
|
||||
dist += (unsigned)(sym_buf_[sx++] & 0xff) << 8;
|
||||
lc = sym_buf_[sx++];
|
||||
if(dist == 0)
|
||||
{
|
||||
send_code(lc, ltree); /* send a literal byte */
|
||||
@@ -1194,9 +1229,9 @@ compress_block(
|
||||
} /* literal or match pair ? */
|
||||
|
||||
/* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
|
||||
BOOST_ASSERT((uInt)(pending_) < lit_bufsize_ + 2*lx);
|
||||
BOOST_ASSERT((uInt)(pending_) < lit_bufsize_ + sx);
|
||||
}
|
||||
while(lx < last_lit_);
|
||||
while(sx < sym_next_);
|
||||
}
|
||||
|
||||
send_code(END_BLOCK, ltree);
|
||||
@@ -1205,9 +1240,9 @@ compress_block(
|
||||
/* Check if the data type is TEXT or BINARY, using the following algorithm:
|
||||
- TEXT if the two conditions below are satisfied:
|
||||
a) There are no non-portable control characters belonging to the
|
||||
"black list" (0..6, 14..25, 28..31).
|
||||
"block list" (0..6, 14..25, 28..31).
|
||||
b) There is at least one printable character belonging to the
|
||||
"white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
|
||||
"allow list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
|
||||
- BINARY otherwise.
|
||||
- The following partially-portable control characters form a
|
||||
"gray list" that is ignored in this detection algorithm:
|
||||
@@ -1218,19 +1253,19 @@ int
|
||||
deflate_stream::
|
||||
detect_data_type()
|
||||
{
|
||||
/* black_mask is the bit mask of black-listed bytes
|
||||
/* block_mask is the bit mask of block-listed bytes
|
||||
* set bits 0..6, 14..25, and 28..31
|
||||
* 0xf3ffc07f = binary 11110011111111111100000001111111
|
||||
*/
|
||||
unsigned long black_mask = 0xf3ffc07fUL;
|
||||
unsigned long block_mask = 0xf3ffc07fUL;
|
||||
int n;
|
||||
|
||||
// Check for non-textual ("black-listed") bytes.
|
||||
for(n = 0; n <= 31; n++, black_mask >>= 1)
|
||||
if((black_mask & 1) && (dyn_ltree_[n].fc != 0))
|
||||
// Check for non-textual ("block-listed") bytes.
|
||||
for(n = 0; n <= 31; n++, block_mask >>= 1)
|
||||
if((block_mask & 1) && (dyn_ltree_[n].fc != 0))
|
||||
return binary;
|
||||
|
||||
// Check for textual ("white-listed") bytes. */
|
||||
// Check for textual ("allow-listed") bytes. */
|
||||
if(dyn_ltree_[9].fc != 0 || dyn_ltree_[10].fc != 0
|
||||
|| dyn_ltree_[13].fc != 0)
|
||||
return text;
|
||||
@@ -1238,7 +1273,7 @@ detect_data_type()
|
||||
if(dyn_ltree_[n].fc != 0)
|
||||
return text;
|
||||
|
||||
/* There are no "black-listed" or "white-listed" bytes:
|
||||
/* There are no "block-listed" or "white-listed" bytes:
|
||||
* this stream either is empty or has tolerated ("gray-listed") bytes only.
|
||||
*/
|
||||
return binary;
|
||||
@@ -1295,9 +1330,9 @@ copy_block(
|
||||
put_short((std::uint16_t)len);
|
||||
put_short((std::uint16_t)~len);
|
||||
}
|
||||
// VFALCO Use memcpy?
|
||||
while (len--)
|
||||
put_byte(*buf++);
|
||||
if(buf)
|
||||
std::memcpy(&pending_buf_[pending_], buf, len);
|
||||
pending_ += len;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -1362,22 +1397,24 @@ void
|
||||
deflate_stream::
|
||||
tr_tally_dist(std::uint16_t dist, std::uint8_t len, bool& flush)
|
||||
{
|
||||
d_buf_[last_lit_] = dist;
|
||||
l_buf_[last_lit_++] = len;
|
||||
sym_buf_[sym_next_++] = dist & 0xFF;
|
||||
sym_buf_[sym_next_++] = dist >> 8;
|
||||
sym_buf_[sym_next_++] = len;
|
||||
dist--;
|
||||
dyn_ltree_[lut_.length_code[len]+literals+1].fc++;
|
||||
dyn_dtree_[d_code(dist)].fc++;
|
||||
flush = (last_lit_ == lit_bufsize_-1);
|
||||
flush = (sym_next_ == sym_end_);
|
||||
}
|
||||
|
||||
void
|
||||
deflate_stream::
|
||||
tr_tally_lit(std::uint8_t c, bool& flush)
|
||||
{
|
||||
d_buf_[last_lit_] = 0;
|
||||
l_buf_[last_lit_++] = c;
|
||||
sym_buf_[sym_next_++] = 0;
|
||||
sym_buf_[sym_next_++] = 0;
|
||||
sym_buf_[sym_next_++] = c;
|
||||
dyn_ltree_[c].fc++;
|
||||
flush = (last_lit_ == lit_bufsize_-1);
|
||||
flush = (sym_next_ == sym_end_);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -1522,6 +1559,8 @@ fill_window(z_params& zs)
|
||||
match_start_ -= wsize;
|
||||
strstart_ -= wsize; // we now have strstart >= max_dist
|
||||
block_start_ -= (long) wsize;
|
||||
if (insert_ > strstart_)
|
||||
insert_ = strstart_;
|
||||
|
||||
/* Slide the hash table (could be avoided with 32 bit values
|
||||
at the expense of memory usage). We slide even when level == 0
|
||||
@@ -1990,7 +2029,7 @@ f_fast(z_params& zs, Flush flush) ->
|
||||
return finish_started;
|
||||
return finish_done;
|
||||
}
|
||||
if(last_lit_)
|
||||
if(sym_next_)
|
||||
{
|
||||
flush_block(zs, false);
|
||||
if(zs.avail_out == 0)
|
||||
@@ -2135,7 +2174,7 @@ f_slow(z_params& zs, Flush flush) ->
|
||||
return finish_started;
|
||||
return finish_done;
|
||||
}
|
||||
if(last_lit_)
|
||||
if(sym_next_)
|
||||
{
|
||||
flush_block(zs, false);
|
||||
if(zs.avail_out == 0)
|
||||
@@ -2221,7 +2260,7 @@ f_rle(z_params& zs, Flush flush) ->
|
||||
return finish_started;
|
||||
return finish_done;
|
||||
}
|
||||
if(last_lit_)
|
||||
if(sym_next_)
|
||||
{
|
||||
flush_block(zs, false);
|
||||
if(zs.avail_out == 0)
|
||||
@@ -2275,7 +2314,7 @@ f_huff(z_params& zs, Flush flush) ->
|
||||
return finish_started;
|
||||
return finish_done;
|
||||
}
|
||||
if(last_lit_)
|
||||
if(sym_next_)
|
||||
{
|
||||
flush_block(zs, false);
|
||||
if(zs.avail_out == 0)
|
||||
|
||||
@@ -113,12 +113,14 @@ doWrite(z_params& zs, Flush flush, error_code& ec)
|
||||
|
||||
if(((! r.in.used() && ! r.out.used()) ||
|
||||
flush == Flush::finish) && ! ec)
|
||||
ec = error::need_buffers;
|
||||
{
|
||||
BOOST_BEAST_ASSIGN_EC(ec, error::need_buffers);
|
||||
}
|
||||
};
|
||||
auto const err =
|
||||
[&](error e)
|
||||
{
|
||||
ec = e;
|
||||
BOOST_BEAST_ASSIGN_EC(ec, e);
|
||||
mode_ = BAD;
|
||||
};
|
||||
|
||||
@@ -516,8 +518,10 @@ doWrite(z_params& zs, Flush flush, error_code& ec)
|
||||
BOOST_FALLTHROUGH;
|
||||
|
||||
case DONE:
|
||||
ec = error::end_of_stream;
|
||||
{
|
||||
BOOST_BEAST_ASSIGN_EC(ec, error::end_of_stream);
|
||||
return done();
|
||||
}
|
||||
|
||||
case BAD:
|
||||
return done();
|
||||
@@ -572,7 +576,7 @@ inflate_table(
|
||||
code *next; // next available space in table
|
||||
std::uint16_t const* base; // base value table to use
|
||||
std::uint16_t const* extra; // extra bits table to use
|
||||
int end; // use base and extra for symbol > end
|
||||
unsigned match; // use base and extra for symbol >= match
|
||||
std::uint16_t count[15+1]; // number of codes of each length
|
||||
std::uint16_t offs[15+1]; // offsets in table for each length
|
||||
|
||||
@@ -584,7 +588,7 @@ inflate_table(
|
||||
// Length codes 257..285 extra
|
||||
static std::uint16_t constexpr lext[31] = {
|
||||
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
||||
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78};
|
||||
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 77, 202};
|
||||
|
||||
// Distance codes 0..29 base
|
||||
static std::uint16_t constexpr dbase[32] = {
|
||||
@@ -666,13 +670,13 @@ inflate_table(
|
||||
left -= count[len];
|
||||
if (left < 0)
|
||||
{
|
||||
ec = error::over_subscribed_length;
|
||||
BOOST_BEAST_ASSIGN_EC(ec, error::over_subscribed_length);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (left > 0 && (type == build::codes || max != 1))
|
||||
{
|
||||
ec = error::incomplete_length_set;
|
||||
BOOST_BEAST_ASSIGN_EC(ec, error::incomplete_length_set);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -722,19 +726,17 @@ inflate_table(
|
||||
{
|
||||
case build::codes:
|
||||
base = extra = work; /* dummy value--not used */
|
||||
end = 19;
|
||||
match = 20;
|
||||
break;
|
||||
case build::lens:
|
||||
base = lbase;
|
||||
base -= 257;
|
||||
extra = lext;
|
||||
extra -= 257;
|
||||
end = 256;
|
||||
match = 257;
|
||||
break;
|
||||
default: /* build::dists */
|
||||
base = dbase;
|
||||
extra = dext;
|
||||
end = -1;
|
||||
match = 0;
|
||||
}
|
||||
|
||||
/* initialize state for loop */
|
||||
@@ -764,15 +766,15 @@ inflate_table(
|
||||
{
|
||||
/* create table entry */
|
||||
here.bits = (std::uint8_t)(len - drop);
|
||||
if ((int)(work[sym]) < end)
|
||||
if (work[sym] + 1U < match)
|
||||
{
|
||||
here.op = (std::uint8_t)0;
|
||||
here.val = work[sym];
|
||||
}
|
||||
else if ((int)(work[sym]) > end)
|
||||
else if (work[sym] >= match)
|
||||
{
|
||||
here.op = (std::uint8_t)(extra[work[sym]]);
|
||||
here.val = base[work[sym]];
|
||||
here.op = (std::uint8_t)(extra[work[sym] - match]);
|
||||
here.val = base[work[sym] - match];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1039,7 +1041,7 @@ inflate_fast(ranges& r, error_code& ec)
|
||||
#ifdef INFLATE_STRICT
|
||||
if(dist > dmax_)
|
||||
{
|
||||
ec = error::invalid_distance;
|
||||
BOOST_BEAST_ASSIGN_EC(ec, error::invalid_distance);
|
||||
mode_ = BAD;
|
||||
break;
|
||||
}
|
||||
@@ -1053,7 +1055,7 @@ inflate_fast(ranges& r, error_code& ec)
|
||||
op = dist - op; // distance back in window
|
||||
if(op > w_.size())
|
||||
{
|
||||
ec = error::invalid_distance;
|
||||
BOOST_BEAST_ASSIGN_EC(ec, error::invalid_distance);
|
||||
mode_ = BAD;
|
||||
break;
|
||||
}
|
||||
@@ -1080,7 +1082,7 @@ inflate_fast(ranges& r, error_code& ec)
|
||||
}
|
||||
else
|
||||
{
|
||||
ec = error::invalid_distance_code;
|
||||
BOOST_BEAST_ASSIGN_EC(ec, error::invalid_distance_code);
|
||||
mode_ = BAD;
|
||||
break;
|
||||
}
|
||||
@@ -1099,7 +1101,7 @@ inflate_fast(ranges& r, error_code& ec)
|
||||
}
|
||||
else
|
||||
{
|
||||
ec = error::invalid_literal_length;
|
||||
BOOST_BEAST_ASSIGN_EC(ec, error::invalid_literal_length);
|
||||
mode_ = BAD;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -66,6 +66,17 @@ enum class error
|
||||
*/
|
||||
end_of_stream,
|
||||
|
||||
/** Preset dictionary required
|
||||
|
||||
This error indicates that a preset dictionary was not provided and is now
|
||||
needed at this point.
|
||||
|
||||
This does not always indicate a failure condition.
|
||||
|
||||
@note This is the same as `Z_NEED_DICT` returned by ZLib.
|
||||
*/
|
||||
need_dict,
|
||||
|
||||
/** Invalid stream or parameters.
|
||||
|
||||
This error is returned when invalid parameters are passed,
|
||||
@@ -95,7 +106,7 @@ enum class error
|
||||
too_many_symbols,
|
||||
|
||||
/// Invalid code lengths
|
||||
invalid_code_lenths,
|
||||
invalid_code_lengths,
|
||||
|
||||
/// Invalid bit length repeat
|
||||
invalid_bit_length_repeat,
|
||||
|
||||
@@ -62,12 +62,13 @@ public:
|
||||
{
|
||||
case error::need_buffers: return "need buffers";
|
||||
case error::end_of_stream: return "unexpected end of deflate stream";
|
||||
case error::need_dict: return "need dict";
|
||||
case error::stream_error: return "stream error";
|
||||
|
||||
case error::invalid_block_type: return "invalid block type";
|
||||
case error::invalid_stored_length: return "invalid stored block length";
|
||||
case error::too_many_symbols: return "too many symbols";
|
||||
case error::invalid_code_lenths: return "invalid code lengths";
|
||||
case error::invalid_code_lengths: return "invalid code lengths";
|
||||
case error::invalid_bit_length_repeat: return "invalid bit length repeat";
|
||||
case error::missing_eob: return "missing end of block code";
|
||||
case error::invalid_literal_length: return "invalid literal/length code";
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
//
|
||||
// This is a derivative work based on Zlib, copyright below:
|
||||
/*
|
||||
Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
|
||||
Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -182,7 +182,7 @@ public:
|
||||
the effects of the flush parameter in this implementation are on the return value
|
||||
of `write` as noted below, when `write` returns early when `Flush::block` or
|
||||
`Flush::trees` is used, and when `write` avoids the allocation of memory for a
|
||||
sliding window when `Flush::finsih` is used.
|
||||
sliding window when `Flush::finish` is used.
|
||||
|
||||
If a preset dictionary is needed after this call,
|
||||
`write` sets `zs.adler` to the Adler-32 checksum of the dictionary chosen by
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
//
|
||||
// This is a derivative work based on Zlib, copyright below:
|
||||
/*
|
||||
Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
|
||||
Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -80,50 +80,120 @@ struct z_params
|
||||
/** A pointer to the next input byte.
|
||||
|
||||
If there is no more input, this may be set to `nullptr`.
|
||||
|
||||
The application must update `next_in` and `avail_in` when
|
||||
`avail_in` has dropped to zero.
|
||||
*/
|
||||
void const* next_in;
|
||||
|
||||
/** The number of bytes of input available at `next_in`.
|
||||
|
||||
If there is no more input, this should be set to zero.
|
||||
|
||||
The application must update `next_in` and `avail_in` when
|
||||
`avail_in` has dropped to zero.
|
||||
*/
|
||||
std::size_t avail_in;
|
||||
|
||||
/** The total number of input bytes read so far.
|
||||
|
||||
This field is set by the compression library and must
|
||||
not be updated by the application.
|
||||
|
||||
This field can also be used for statistics or progress
|
||||
reports.
|
||||
|
||||
After compression, total_in holds the total size of the
|
||||
uncompressed data and may be saved for use by the
|
||||
decompressor (particularly if the decompressor wants
|
||||
to decompress everything in a single step).
|
||||
|
||||
*/
|
||||
std::size_t total_in = 0;
|
||||
|
||||
/** A pointer to the next output byte.
|
||||
|
||||
The application must update `next_out` and `avail_out`
|
||||
when avail_out has dropped to zero.
|
||||
*/
|
||||
void* next_out;
|
||||
|
||||
/** The remaining bytes of space at `next_out`.
|
||||
|
||||
The application must update `next_out` and `avail_out`
|
||||
when avail_out has dropped to zero.
|
||||
*/
|
||||
std::size_t avail_out;
|
||||
|
||||
/** The total number of bytes output so far.
|
||||
|
||||
This field is set by the compression library and must
|
||||
not be updated by the application.
|
||||
|
||||
This field can also be used for statistics or progress
|
||||
reports.
|
||||
*/
|
||||
std::size_t total_out = 0;
|
||||
|
||||
int data_type = unknown; // best guess about the data type: binary or text
|
||||
/** Best guess about the data type: binary or text
|
||||
|
||||
This represents binary or text for deflate, or
|
||||
the decoding state for inflate.
|
||||
*/
|
||||
int data_type = unknown;
|
||||
};
|
||||
|
||||
/** Flush option.
|
||||
|
||||
The allowed flush values for the @ref deflate_stream::write
|
||||
and @ref inflate_stream::write functions.
|
||||
|
||||
Please refer to @ref deflate_stream::write and
|
||||
@ref inflate_stream::write for details.
|
||||
|
||||
@see
|
||||
deflate_stream::write,
|
||||
inflate_stream::write
|
||||
|
||||
*/
|
||||
enum class Flush
|
||||
{
|
||||
// order matters
|
||||
|
||||
/// No policy
|
||||
none,
|
||||
|
||||
/// Flush all pending output on a bit boundary and hold up to seven bits
|
||||
block,
|
||||
|
||||
/// Flush all pending output on a bit boundary
|
||||
partial,
|
||||
|
||||
/// Flush all pending output on a byte boundary
|
||||
sync,
|
||||
|
||||
/// Flush all pending output on a byte boundary and reset state
|
||||
full,
|
||||
|
||||
/// Compress the input left in a single step
|
||||
finish,
|
||||
|
||||
/// Flush output as in Flush::block or at the end of each deflate block header
|
||||
trees
|
||||
};
|
||||
|
||||
/* compression levels */
|
||||
/** Compression levels.
|
||||
|
||||
The compression levels go from 0 and 9: 1 gives best speed, 9 gives
|
||||
best compression.
|
||||
|
||||
Compression level 0 gives no compression at all. The input data is
|
||||
simply copied a block at a time.
|
||||
|
||||
A compression level 6 is usually a default compromise between
|
||||
speed and compression.
|
||||
|
||||
*/
|
||||
enum compression
|
||||
{
|
||||
none = 0,
|
||||
|
||||
Reference in New Issue
Block a user