1
0
Fork 0

Merging upstream version 1.25~rc1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-21 11:33:25 +01:00
parent 1d67e88e3c
commit b8e73cb85f
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
39 changed files with 978 additions and 742 deletions

View file

@ -26,6 +26,7 @@ class Range_decoder
uint32_t range;
const int infd; // input file descriptor
bool at_stream_end;
bool nonzero_;
bool read_block();
@ -42,11 +43,12 @@ public:
code( 0 ),
range( 0xFFFFFFFFU ),
infd( ifd ),
at_stream_end( false )
at_stream_end( false ), nonzero_( false )
{}
~Range_decoder() { delete[] buffer; }
bool nonzero() const { return nonzero_; }
unsigned get_code() const { return code; }
bool finished() { return pos >= stream_pos && !read_block(); }
@ -110,8 +112,10 @@ public:
{
code = 0;
range = 0xFFFFFFFFU;
// check first byte of the LZMA stream
if( get_byte() != 0 && !ignore_nonzero ) return false;
// check first byte of the LZMA stream without reading it
nonzero_ = buffer[pos] != 0;
if( nonzero_ && !ignore_nonzero ) return false;
get_byte(); // discard first byte of the LZMA stream
for( int i = 0; i < 4; ++i ) code = ( code << 8 ) | get_byte();
return true;
}
@ -131,7 +135,7 @@ public:
range >>= 1;
// symbol <<= 1;
// if( code >= range ) { code -= range; symbol |= 1; }
const bool bit = ( code >= range );
const bool bit = code >= range;
symbol <<= 1; symbol += bit;
code -= range & ( 0U - bit );
}
@ -329,14 +333,14 @@ class LZ_decoder
bool fast, fast2;
if( lpos > distance )
{
fast = ( len < dictionary_size - lpos );
fast2 = ( fast && len <= lpos - i );
fast = len < dictionary_size - lpos;
fast2 = fast && len <= lpos - i;
}
else
{
i += dictionary_size;
fast = ( len < dictionary_size - i ); // (i == pos) may happen
fast2 = ( fast && len <= i - lpos );
fast = len < dictionary_size - i; // (i == pos) may happen
fast2 = fast && len <= i - lpos;
}
if( fast ) // no wrap
{