summaryrefslogtreecommitdiffstats
path: root/decoder.c
diff options
context:
space:
mode:
Diffstat (limited to 'decoder.c')
-rw-r--r--decoder.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/decoder.c b/decoder.c
index c079504..369dc86 100644
--- a/decoder.c
+++ b/decoder.c
@@ -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 );