diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 05:04:21 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 05:04:21 +0000 |
commit | 0fff9dab63d2ac6b195b1a4a0d1f241663294337 (patch) | |
tree | 8eb7409dd1100c166d146053a4415d5be5d738aa /decoder.c | |
parent | Adding debian version 1.4-1. (diff) | |
download | lunzip-0fff9dab63d2ac6b195b1a4a0d1f241663294337.tar.xz lunzip-0fff9dab63d2ac6b195b1a4a0d1f241663294337.zip |
Merging upstream version 1.5~rc1.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'decoder.c')
-rw-r--r-- | decoder.c | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -87,6 +87,15 @@ static int writeblock( const int fd, const uint8_t * const buf, const int size ) } +int seek_read( const int fd, uint8_t * const buf, const int size, + const int offset ) + { + if( lseek( fd, offset, SEEK_END ) >= 0 ) + return readblock( fd, buf, size ); + return 0; + } + + bool Rd_read_block( struct Range_decoder * const rdec ) { if( !rdec->at_stream_end ) @@ -193,6 +202,10 @@ int LZd_decode_member( struct LZ_decoder * const decoder, struct Pretty_print * const pp ) { struct Range_decoder * const rdec = decoder->rdec; + void (* const copy_block) + ( struct LZ_decoder * const decoder, const int distance, int len ) = + ( decoder->buffer_size >= decoder->dictionary_size ) ? + &LZd_copy_block : &LZd_copy_block2; unsigned rep0 = 0; /* rep[0-3] latest four distances */ unsigned rep1 = 0; /* used for efficient coding of */ unsigned rep2 = 0; /* repeated distances */ @@ -293,10 +306,10 @@ int LZd_decode_member( struct LZ_decoder * const decoder, rep3 = rep2; rep2 = rep1; rep1 = rep0_saved; state = St_set_match( state ); if( rep0 >= (unsigned)decoder->dictionary_size || - ( rep0 >= (unsigned)decoder->pos && !decoder->partial_data_pos ) ) + rep0 >= LZd_data_position( decoder ) ) { LZd_flush_data( decoder ); return 1; } } - LZd_copy_block( decoder, rep0, len ); + copy_block( decoder, rep0, len ); } } LZd_flush_data( decoder ); |