From 650fbd7ceb5dac028429503a1cfa5517554c941e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 25 Jan 2021 14:57:00 +0100 Subject: Adding upstream version 1.12. Signed-off-by: Daniel Baumann --- decoder.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'decoder.c') diff --git a/decoder.c b/decoder.c index 3dc62cc..82472b3 100644 --- a/decoder.c +++ b/decoder.c @@ -1,27 +1,27 @@ -/* Lzlib - Compression library for the lzip format - Copyright (C) 2009-2019 Antonio Diaz Diaz. +/* Lzlib - Compression library for the lzip format + Copyright (C) 2009-2021 Antonio Diaz Diaz. - This library is free software. Redistribution and use in source and - binary forms, with or without modification, are permitted provided - that the following conditions are met: + This library is free software. Redistribution and use in source and + binary forms, with or without modification, are permitted provided + that the following conditions are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions, and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions, and the following disclaimer in the + documentation and/or other materials provided with the distribution. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ static int LZd_try_verify_trailer( struct LZ_decoder * const d ) { Lzip_trailer trailer; - if( Rd_available_bytes( d->rdec ) < Lt_size && !d->rdec->at_stream_end ) - return 0; + if( Rd_available_bytes( d->rdec ) < Lt_size ) + { if( !d->rdec->at_stream_end ) return 0; else return 2; } d->verify_trailer_pending = false; d->member_finished = true; @@ -40,10 +40,10 @@ static int LZd_decode_member( struct LZ_decoder * const d ) { struct Range_decoder * const rdec = d->rdec; State * const state = &d->state; - /* unsigned old_mpos = d->rdec->member_position; */ + /* unsigned old_mpos = rdec->member_position; */ if( d->member_finished ) return 0; - if( !Rd_try_reload( rdec, false ) ) + if( !Rd_try_reload( rdec ) ) { if( !rdec->at_stream_end ) return 0; else return 2; } if( d->verify_trailer_pending ) return LZd_try_verify_trailer( d ); @@ -51,7 +51,7 @@ static int LZd_decode_member( struct LZ_decoder * const d ) { int len; const int pos_state = LZd_data_position( d ) & pos_state_mask; - /* const unsigned mpos = d->rdec->member_position; + /* const unsigned mpos = rdec->member_position; if( mpos - old_mpos > rd_min_available_bytes ) return 5; old_mpos = mpos; */ if( !Rd_enough_available_bytes( rdec ) ) /* check unexpected EOF */ @@ -123,6 +123,9 @@ static int LZd_decode_member( struct LZ_decoder * const d ) if( distance == 0xFFFFFFFFU ) /* marker found */ { Rd_normalize( rdec ); + /* const unsigned mpos = rdec->member_position; + if( mpos - old_mpos > rd_min_available_bytes ) return 5; + old_mpos = mpos; */ if( len == min_match_len ) /* End Of Stream marker */ { d->verify_trailer_pending = true; @@ -130,7 +133,8 @@ static int LZd_decode_member( struct LZ_decoder * const d ) } if( len == min_match_len + 1 ) /* Sync Flush marker */ { - if( Rd_try_reload( rdec, true ) ) { /*old_mpos += 5;*/ continue; } + rdec->reload_pending = true; + if( Rd_try_reload( rdec ) ) continue; else { if( !rdec->at_stream_end ) return 0; else break; } } return 4; -- cgit v1.2.3