diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 05:04:14 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 05:04:14 +0000 |
commit | f6013e698f91bdd085cff4d0da0d49cf3877477f (patch) | |
tree | d9391a6f56d39c88e664217a54c641db29dfb615 /decoder.c | |
parent | Adding upstream version 1.4. (diff) | |
download | lunzip-f6013e698f91bdd085cff4d0da0d49cf3877477f.tar.xz lunzip-f6013e698f91bdd085cff4d0da0d49cf3877477f.zip |
Adding upstream version 1.5~rc1.upstream/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 ); |