lzlib 1.0.7.2 → 1.0.7.3
raw patch · 16 files changed
+105/−118 lines, 16 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−0
- cbits/cbuffer.c +2/−2
- cbits/decoder.c +7/−7
- cbits/decoder.h +9/−9
- cbits/encoder.c +4/−3
- cbits/encoder.h +1/−1
- cbits/encoder_base.c +2/−4
- cbits/encoder_base.h +7/−10
- cbits/fast_encoder.c +1/−1
- cbits/fast_encoder.h +1/−1
- cbits/lzip.h +22/−26
- cbits/lzlib.c +40/−40
- cbits/lzlib.h +3/−3
- lzlib.cabal +1/−2
- stack.yaml +0/−7
- test/Spec.hs +1/−2
CHANGELOG.md view
@@ -1,5 +1,9 @@ # lzlib +## 1.0.7.3++ * Bump C sources to lzlib 1.14+ ## 1.0.7.2 * Bump C sources to lzlib 1.13
cbits/cbuffer.c view
@@ -1,5 +1,5 @@ /* Lzlib - Compression library for the lzip format- Copyright (C) 2009-2022 Antonio Diaz Diaz.+ Copyright (C) 2009-2024 Antonio Diaz Diaz. This library is free software. Redistribution and use in source and binary forms, with or without modification, are permitted provided@@ -33,7 +33,7 @@ cb->put = 0; cb->buffer = ( cb->buffer_size > 1 ) ? (uint8_t *)malloc( cb->buffer_size ) : 0;- return ( cb->buffer != 0 );+ return cb->buffer != 0; } static inline void Cb_free( struct Circular_buffer * const cb )
cbits/decoder.c view
@@ -1,5 +1,5 @@ /* Lzlib - Compression library for the lzip format- Copyright (C) 2009-2022 Antonio Diaz Diaz.+ Copyright (C) 2009-2024 Antonio Diaz Diaz. This library is free software. Redistribution and use in source and binary forms, with or without modification, are permitted provided@@ -17,12 +17,12 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ -static int LZd_try_verify_trailer( struct LZ_decoder * const d )+static int LZd_try_check_trailer( struct LZ_decoder * const d ) { Lzip_trailer trailer; 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->check_trailer_pending = false; d->member_finished = true; if( Rd_read_data( d->rdec, trailer, Lt_size ) == Lt_size &&@@ -45,7 +45,7 @@ if( d->member_finished ) return 0; 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 );+ if( d->check_trailer_pending ) return LZd_try_check_trailer( d ); while( !Rd_finished( rdec ) ) {@@ -121,14 +121,14 @@ old_mpos = mpos; */ if( len == min_match_len ) /* End Of Stream marker */ {- d->verify_trailer_pending = true;- return LZd_try_verify_trailer( d );+ d->check_trailer_pending = true;+ return LZd_try_check_trailer( d ); } if( len == min_match_len + 1 ) /* Sync Flush marker */ { rdec->reload_pending = true; if( Rd_try_reload( rdec ) ) continue;- else { if( !rdec->at_stream_end ) return 0; else break; }+ if( !rdec->at_stream_end ) return 0; else break; } return 4; }
cbits/decoder.h view
@@ -1,5 +1,5 @@ /* Lzlib - Compression library for the lzip format- Copyright (C) 2009-2022 Antonio Diaz Diaz.+ Copyright (C) 2009-2024 Antonio Diaz Diaz. This library is free software. Redistribution and use in source and binary forms, with or without modification, are permitted provided@@ -50,7 +50,7 @@ { rdec->at_stream_end = true; } static inline bool Rd_enough_available_bytes( const struct Range_decoder * const rdec )- { return ( Cb_used_bytes( &rdec->cb ) >= rd_min_available_bytes ); }+ { return Cb_used_bytes( &rdec->cb ) >= rd_min_available_bytes; } static inline unsigned Rd_available_bytes( const struct Range_decoder * const rdec ) { return Cb_used_bytes( &rdec->cb ); }@@ -92,7 +92,7 @@ header[i] = rdec->cb.buffer[get]; if( ++get >= rdec->cb.buffer_size ) get = 0; }- if( Lh_verify( header ) ) return true;+ if( Lh_check( header ) ) return true; } if( ++rdec->cb.get >= rdec->cb.buffer_size ) rdec->cb.get = 0; ++*skippedp;@@ -137,12 +137,12 @@ { if( rdec->reload_pending && Rd_available_bytes( rdec ) >= 5 ) {- int i; rdec->reload_pending = false; rdec->code = 0;- for( i = 0; i < 5; ++i ) rdec->code = (rdec->code << 8) | Rd_get_byte( rdec ); rdec->range = 0xFFFFFFFFU;- rdec->code &= rdec->range; /* make sure that first byte is discarded */+ Rd_get_byte( rdec ); /* discard first byte of the LZMA stream */+ int i; for( i = 0; i < 4; ++i )+ rdec->code = (rdec->code << 8) | Rd_get_byte( rdec ); } return !rdec->reload_pending; }@@ -334,8 +334,8 @@ struct Range_decoder * rdec; unsigned dictionary_size; uint32_t crc;+ bool check_trailer_pending; bool member_finished;- bool verify_trailer_pending; bool pos_wrapped; unsigned rep0; /* rep[0-3] latest four distances */ unsigned rep1; /* used for efficient coding of */@@ -423,8 +423,8 @@ d->rdec = rde; d->dictionary_size = dict_size; d->crc = 0xFFFFFFFFU;+ d->check_trailer_pending = false; d->member_finished = false;- d->verify_trailer_pending = false; d->pos_wrapped = false; /* prev_byte of first byte; also for LZd_peek( 0 ) on corrupt file */ d->cb.buffer[d->cb.buffer_size-1] = 0;@@ -453,7 +453,7 @@ { Cb_free( &d->cb ); } static inline bool LZd_member_finished( const struct LZ_decoder * const d )- { return ( d->member_finished && Cb_empty( &d->cb ) ); }+ { return d->member_finished && Cb_empty( &d->cb ); } static inline unsigned LZd_crc( const struct LZ_decoder * const d ) { return d->crc ^ 0xFFFFFFFFU; }
cbits/encoder.c view
@@ -1,5 +1,5 @@ /* Lzlib - Compression library for the lzip format- Copyright (C) 2009-2022 Antonio Diaz Diaz.+ Copyright (C) 2009-2024 Antonio Diaz Diaz. This library is free software. Redistribution and use in source and binary forms, with or without modification, are permitted provided@@ -200,8 +200,6 @@ } const int pos_state = Mb_data_position( &e->eb.mb ) & pos_state_mask;- const int match_price = price1( e->eb.bm_match[state][pos_state] );- const int rep_match_price = match_price + price1( e->eb.bm_rep[state] ); const uint8_t prev_byte = Mb_peek( &e->eb.mb, 1 ); const uint8_t cur_byte = Mb_peek( &e->eb.mb, 0 ); const uint8_t match_byte = Mb_peek( &e->eb.mb, reps[0] + 1 );@@ -212,6 +210,9 @@ else e->trials[1].price += LZeb_price_matched( &e->eb, prev_byte, cur_byte, match_byte ); e->trials[1].dis4 = -1; /* literal */++ const int match_price = price1( e->eb.bm_match[state][pos_state] );+ const int rep_match_price = match_price + price1( e->eb.bm_rep[state] ); if( match_byte == cur_byte ) Tr_update( &e->trials[1], rep_match_price +
cbits/encoder.h view
@@ -1,5 +1,5 @@ /* Lzlib - Compression library for the lzip format- Copyright (C) 2009-2022 Antonio Diaz Diaz.+ Copyright (C) 2009-2024 Antonio Diaz Diaz. This library is free software. Redistribution and use in source and binary forms, with or without modification, are permitted provided
cbits/encoder_base.c view
@@ -1,5 +1,5 @@ /* Lzlib - Compression library for the lzip format- Copyright (C) 2009-2022 Antonio Diaz Diaz.+ Copyright (C) 2009-2024 Antonio Diaz Diaz. This library is free software. Redistribution and use in source and binary forms, with or without modification, are permitted provided@@ -140,9 +140,7 @@ Lt_set_data_crc( trailer, LZeb_crc( eb ) ); Lt_set_data_size( trailer, Mb_data_position( &eb->mb ) ); Lt_set_member_size( trailer, Re_member_position( &eb->renc ) + Lt_size );- int i;- for( i = 0; i < Lt_size; ++i )- Cb_put_byte( &eb->renc.cb, trailer[i] );+ int i; for( i = 0; i < Lt_size; ++i ) Cb_put_byte( &eb->renc.cb, trailer[i] ); }
cbits/encoder_base.h view
@@ -1,5 +1,5 @@ /* Lzlib - Compression library for the lzip format- Copyright (C) 2009-2022 Antonio Diaz Diaz.+ Copyright (C) 2009-2024 Antonio Diaz Diaz. This library is free software. Redistribution and use in source and binary forms, with or without modification, are permitted provided@@ -142,7 +142,7 @@ { return get_price( bit_model_total - probability ); } static inline int price_bit( const Bit_model bm, const bool bit )- { return ( bit ? price1( bm ) : price0( bm ) ); }+ { return bit ? price1( bm ) : price0( bm ); } static inline int price_symbol3( const Bit_model bm[], int symbol )@@ -276,8 +276,8 @@ static inline bool Mb_enough_available_bytes( const struct Matchfinder_base * const mb )- { return ( mb->pos + mb->after_size <= mb->stream_pos ||- ( Mb_flushing_or_end( mb ) && mb->pos < mb->stream_pos ) ); }+ { return mb->pos + mb->after_size <= mb->stream_pos ||+ ( Mb_flushing_or_end( mb ) && mb->pos < mb->stream_pos ); } static inline const uint8_t * Mb_ptr_to_current_pos( const struct Matchfinder_base * const mb )@@ -340,7 +340,6 @@ static inline void Re_reset( struct Range_encoder * const renc, const unsigned dictionary_size ) {- int i; Cb_reset( &renc->cb ); renc->low = 0; renc->partial_member_pos = 0;@@ -348,8 +347,7 @@ renc->ff_count = 0; renc->cache = 0; Lh_set_dictionary_size( renc->header, dictionary_size );- for( i = 0; i < Lh_size; ++i )- Cb_put_byte( &renc->cb, renc->header[i] );+ int i; for( i = 0; i < Lh_size; ++i ) Cb_put_byte( &renc->cb, renc->header[i] ); } static inline bool Re_init( struct Range_encoder * const renc,@@ -398,8 +396,7 @@ { renc->range >>= 1; if( symbol & mask ) renc->low += renc->range;- if( renc->range <= 0x00FFFFFFU )- { renc->range <<= 8; Re_shift_low( renc ); }+ if( renc->range <= 0x00FFFFFFU ) { renc->range <<= 8; Re_shift_low( renc ); } } } @@ -559,7 +556,7 @@ } static inline bool LZeb_member_finished( const struct LZ_encoder_base * const eb )- { return ( eb->member_finished && Cb_empty( &eb->renc.cb ) ); }+ { return eb->member_finished && Cb_empty( &eb->renc.cb ); } static inline void LZeb_free( struct LZ_encoder_base * const eb ) { Re_free( &eb->renc ); Mb_free( &eb->mb ); }
cbits/fast_encoder.c view
@@ -1,5 +1,5 @@ /* Lzlib - Compression library for the lzip format- Copyright (C) 2009-2022 Antonio Diaz Diaz.+ Copyright (C) 2009-2024 Antonio Diaz Diaz. This library is free software. Redistribution and use in source and binary forms, with or without modification, are permitted provided
cbits/fast_encoder.h view
@@ -1,5 +1,5 @@ /* Lzlib - Compression library for the lzip format- Copyright (C) 2009-2022 Antonio Diaz Diaz.+ Copyright (C) 2009-2024 Antonio Diaz Diaz. This library is free software. Redistribution and use in source and binary forms, with or without modification, are permitted provided
cbits/lzip.h view
@@ -1,5 +1,5 @@ /* Lzlib - Compression library for the lzip format- Copyright (C) 2009-2022 Antonio Diaz Diaz.+ Copyright (C) 2009-2024 Antonio Diaz Diaz. This library is free software. Redistribution and use in source and binary forms, with or without modification, are permitted provided@@ -35,17 +35,13 @@ static const State next[states] = { 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 }; return next[st]; }- static inline State St_set_char_rep() { return 8; }- static inline State St_set_match( const State st )- { return ( ( st < 7 ) ? 7 : 10 ); }-+ { return ( st < 7 ) ? 7 : 10; } static inline State St_set_rep( const State st )- { return ( ( st < 7 ) ? 8 : 11 ); }-+ { return ( st < 7 ) ? 8 : 11; } static inline State St_set_short_rep( const State st )- { return ( ( st < 7 ) ? 9 : 11 ); }+ { return ( st < 7 ) ? 9 : 11; } enum {@@ -182,8 +178,8 @@ static inline bool isvalid_ds( const unsigned dictionary_size )- { return ( dictionary_size >= min_dictionary_size &&- dictionary_size <= max_dictionary_size ); }+ { return dictionary_size >= min_dictionary_size &&+ dictionary_size <= max_dictionary_size; } static inline int real_bits( unsigned value )@@ -196,43 +192,43 @@ static const uint8_t lzip_magic[4] = { 0x4C, 0x5A, 0x49, 0x50 }; /* "LZIP" */ -typedef uint8_t Lzip_header[6]; /* 0-3 magic bytes */+enum { Lh_size = 6 };+typedef uint8_t Lzip_header[Lh_size]; /* 0-3 magic bytes */ /* 4 version */ /* 5 coded dictionary size */-enum { Lh_size = 6 }; static inline void Lh_set_magic( Lzip_header data ) { memcpy( data, lzip_magic, 4 ); data[4] = 1; } -static inline bool Lh_verify_magic( const Lzip_header data )- { return ( memcmp( data, lzip_magic, 4 ) == 0 ); }+static inline bool Lh_check_magic( const Lzip_header data )+ { return memcmp( data, lzip_magic, 4 ) == 0; } /* detect (truncated) header */-static inline bool Lh_verify_prefix( const Lzip_header data, const int sz )+static inline bool Lh_check_prefix( const Lzip_header data, const int sz ) { int i; for( i = 0; i < sz && i < 4; ++i ) if( data[i] != lzip_magic[i] ) return false;- return ( sz > 0 );+ return sz > 0; } /* detect corrupt header */-static inline bool Lh_verify_corrupt( const Lzip_header data )+static inline bool Lh_check_corrupt( const Lzip_header data ) { int matches = 0; int i; for( i = 0; i < 4; ++i ) if( data[i] == lzip_magic[i] ) ++matches;- return ( matches > 1 && matches < 4 );+ return matches > 1 && matches < 4; } static inline uint8_t Lh_version( const Lzip_header data ) { return data[4]; } -static inline bool Lh_verify_version( const Lzip_header data )- { return ( data[4] == 1 ); }+static inline bool Lh_check_version( const Lzip_header data )+ { return data[4] == 1; } static inline unsigned Lh_get_dictionary_size( const Lzip_header data ) {- unsigned sz = ( 1 << ( data[5] & 0x1F ) );+ unsigned sz = 1 << ( data[5] & 0x1F ); if( sz > min_dictionary_size ) sz -= ( sz / 16 ) * ( ( data[5] >> 5 ) & 7 ); return sz;@@ -249,23 +245,23 @@ unsigned i; for( i = 7; i >= 1; --i ) if( base_size - ( i * fraction ) >= sz )- { data[5] |= ( i << 5 ); break; }+ { data[5] |= i << 5; break; } } return true; } -static inline bool Lh_verify( const Lzip_header data )+static inline bool Lh_check( const Lzip_header data ) {- return Lh_verify_magic( data ) && Lh_verify_version( data ) &&+ return Lh_check_magic( data ) && Lh_check_version( data ) && isvalid_ds( Lh_get_dictionary_size( data ) ); } -typedef uint8_t Lzip_trailer[20];+enum { Lt_size = 20 };+typedef uint8_t Lzip_trailer[Lt_size]; /* 0-3 CRC32 of the uncompressed data */ /* 4-11 size of the uncompressed data */ /* 12-19 member size including header and trailer */-enum { Lt_size = 20 }; static inline unsigned Lt_get_data_crc( const Lzip_trailer data ) {
cbits/lzlib.c view
@@ -1,5 +1,5 @@ /* Lzlib - Compression library for the lzip format- Copyright (C) 2009-2022 Antonio Diaz Diaz.+ Copyright (C) 2009-2024 Antonio Diaz Diaz. This library is free software. Redistribution and use in source and binary forms, with or without modification, are permitted provided@@ -86,7 +86,7 @@ } -static bool verify_encoder( struct LZ_Encoder * const e )+static bool check_encoder( struct LZ_Encoder * const e ) { if( !e ) return false; if( !e->lz_encoder_base || ( !e->lz_encoder && !e->flz_encoder ) ||@@ -96,7 +96,7 @@ } -static bool verify_decoder( struct LZ_Decoder * const d )+static bool check_decoder( struct LZ_Decoder * const d ) { if( !d ) return false; if( !d->rdec )@@ -189,7 +189,7 @@ int LZ_compress_finish( struct LZ_Encoder * const e ) {- if( !verify_encoder( e ) || e->fatal ) return -1;+ if( !check_encoder( e ) || e->fatal ) return -1; Mb_finish( &e->lz_encoder_base->mb ); /* if (open --> write --> finish) use same dictionary size as lzip. */ /* this does not save any memory. */@@ -208,7 +208,7 @@ int LZ_compress_restart_member( struct LZ_Encoder * const e, const unsigned long long member_size ) {- if( !verify_encoder( e ) || e->fatal ) return -1;+ if( !check_encoder( e ) || e->fatal ) return -1; if( !LZeb_member_finished( e->lz_encoder_base ) ) { e->lz_errno = LZ_sequence_error; return -1; } if( member_size < min_dictionary_size )@@ -226,7 +226,7 @@ int LZ_compress_sync_flush( struct LZ_Encoder * const e ) {- if( !verify_encoder( e ) || e->fatal ) return -1;+ if( !check_encoder( e ) || e->fatal ) return -1; if( !e->lz_encoder_base->mb.at_stream_end ) e->lz_encoder_base->mb.sync_flush_pending = true; return 0;@@ -236,7 +236,7 @@ int LZ_compress_read( struct LZ_Encoder * const e, uint8_t * const buffer, const int size ) {- if( !verify_encoder( e ) || e->fatal ) return -1;+ if( !check_encoder( e ) || e->fatal ) return -1; if( size < 0 ) return 0; { struct LZ_encoder_base * const eb = e->lz_encoder_base;@@ -258,14 +258,14 @@ int LZ_compress_write( struct LZ_Encoder * const e, const uint8_t * const buffer, const int size ) {- if( !verify_encoder( e ) || e->fatal ) return -1;+ if( !check_encoder( e ) || e->fatal ) return -1; return Mb_write_data( &e->lz_encoder_base->mb, buffer, size ); } int LZ_compress_write_size( struct LZ_Encoder * const e ) {- if( !verify_encoder( e ) || e->fatal ) return -1;+ if( !check_encoder( e ) || e->fatal ) return -1; return Mb_free_bytes( &e->lz_encoder_base->mb ); } @@ -279,43 +279,43 @@ int LZ_compress_finished( struct LZ_Encoder * const e ) {- if( !verify_encoder( e ) ) return -1;- return ( Mb_data_finished( &e->lz_encoder_base->mb ) &&- LZeb_member_finished( e->lz_encoder_base ) );+ if( !check_encoder( e ) ) return -1;+ return Mb_data_finished( &e->lz_encoder_base->mb ) &&+ LZeb_member_finished( e->lz_encoder_base ); } int LZ_compress_member_finished( struct LZ_Encoder * const e ) {- if( !verify_encoder( e ) ) return -1;+ if( !check_encoder( e ) ) return -1; return LZeb_member_finished( e->lz_encoder_base ); } unsigned long long LZ_compress_data_position( struct LZ_Encoder * const e ) {- if( !verify_encoder( e ) ) return 0;+ if( !check_encoder( e ) ) return 0; return Mb_data_position( &e->lz_encoder_base->mb ); } unsigned long long LZ_compress_member_position( struct LZ_Encoder * const e ) {- if( !verify_encoder( e ) ) return 0;+ if( !check_encoder( e ) ) return 0; return Re_member_position( &e->lz_encoder_base->renc ); } unsigned long long LZ_compress_total_in_size( struct LZ_Encoder * const e ) {- if( !verify_encoder( e ) ) return 0;+ if( !check_encoder( e ) ) return 0; return e->partial_in_size + Mb_data_position( &e->lz_encoder_base->mb ); } unsigned long long LZ_compress_total_out_size( struct LZ_Encoder * const e ) {- if( !verify_encoder( e ) ) return 0;+ if( !check_encoder( e ) ) return 0; return e->partial_out_size + Re_member_position( &e->lz_encoder_base->renc ); } @@ -352,7 +352,7 @@ int LZ_decompress_finish( struct LZ_Decoder * const d ) {- if( !verify_decoder( d ) || d->fatal ) return -1;+ if( !check_decoder( d ) || d->fatal ) return -1; if( d->seeking ) { d->seeking = false; d->partial_in_size += Rd_purge( d->rdec ); } else Rd_finish( d->rdec );@@ -362,7 +362,7 @@ int LZ_decompress_reset( struct LZ_Decoder * const d ) {- if( !verify_decoder( d ) ) return -1;+ if( !check_decoder( d ) ) return -1; if( d->lz_decoder ) { LZd_free( d->lz_decoder ); free( d->lz_decoder ); d->lz_decoder = 0; } d->partial_in_size = 0;@@ -379,7 +379,7 @@ int LZ_decompress_sync_to_member( struct LZ_Decoder * const d ) { unsigned skipped = 0;- if( !verify_decoder( d ) ) return -1;+ if( !check_decoder( d ) ) return -1; if( d->lz_decoder ) { LZd_free( d->lz_decoder ); free( d->lz_decoder ); d->lz_decoder = 0; } if( Rd_find_header( d->rdec, &skipped ) ) d->seeking = false;@@ -399,7 +399,7 @@ uint8_t * const buffer, const int size ) { int result;- if( !verify_decoder( d ) ) return -1;+ if( !check_decoder( d ) ) return -1; if( size < 0 ) return 0; if( d->fatal ) /* don't return error until pending bytes are read */ { if( d->lz_decoder && !Cb_empty( &d->lz_decoder->cb ) ) goto get_data;@@ -422,20 +422,20 @@ rd = Rd_read_data( d->rdec, d->member_header, Lh_size ); if( rd < Lh_size || Rd_finished( d->rdec ) ) /* End Of File */ {- if( rd <= 0 || Lh_verify_prefix( d->member_header, rd ) )+ if( rd <= 0 || Lh_check_prefix( d->member_header, rd ) ) d->lz_errno = LZ_unexpected_eof; else d->lz_errno = LZ_header_error; d->fatal = true; return -1; }- if( !Lh_verify_magic( d->member_header ) )+ if( !Lh_check_magic( d->member_header ) ) { /* unreading the header prevents sync_to_member from skipping a member if leading garbage is shorter than a full header; "lgLZIP\x01\x0C" */ if( Rd_unread_data( d->rdec, rd ) ) {- if( d->first_header || !Lh_verify_corrupt( d->member_header ) )+ if( d->first_header || !Lh_check_corrupt( d->member_header ) ) d->lz_errno = LZ_header_error; else d->lz_errno = LZ_data_error; /* corrupt header */@@ -445,12 +445,12 @@ d->fatal = true; return -1; }- if( !Lh_verify_version( d->member_header ) ||+ if( !Lh_check_version( d->member_header ) || !isvalid_ds( Lh_get_dictionary_size( d->member_header ) ) ) { /* Skip a possible "LZIP" leading garbage; "LZIPLZIP\x01\x0C". Leave member_pos pointing to the first error. */- if( Rd_unread_data( d->rdec, 1 + !Lh_verify_version( d->member_header ) ) )+ if( Rd_unread_data( d->rdec, 1 + !Lh_check_version( d->member_header ) ) ) d->lz_errno = LZ_data_error; /* bad version or bad dict size */ else d->lz_errno = LZ_library_error;@@ -500,7 +500,7 @@ const uint8_t * const buffer, const int size ) { int result;- if( !verify_decoder( d ) || d->fatal ) return -1;+ if( !check_decoder( d ) || d->fatal ) return -1; if( size < 0 ) return 0; result = Rd_write_data( d->rdec, buffer, size );@@ -521,7 +521,7 @@ int LZ_decompress_write_size( struct LZ_Decoder * const d ) {- if( !verify_decoder( d ) || d->fatal ) return -1;+ if( !check_decoder( d ) || d->fatal ) return -1; return Rd_free_bytes( d->rdec ); } @@ -535,36 +535,36 @@ int LZ_decompress_finished( struct LZ_Decoder * const d ) {- if( !verify_decoder( d ) || d->fatal ) return -1;- return ( Rd_finished( d->rdec ) &&- ( !d->lz_decoder || LZd_member_finished( d->lz_decoder ) ) );+ if( !check_decoder( d ) || d->fatal ) return -1;+ return Rd_finished( d->rdec ) &&+ ( !d->lz_decoder || LZd_member_finished( d->lz_decoder ) ); } int LZ_decompress_member_finished( struct LZ_Decoder * const d ) {- if( !verify_decoder( d ) || d->fatal ) return -1;- return ( d->lz_decoder && LZd_member_finished( d->lz_decoder ) );+ if( !check_decoder( d ) || d->fatal ) return -1;+ return d->lz_decoder && LZd_member_finished( d->lz_decoder ); } int LZ_decompress_member_version( struct LZ_Decoder * const d ) {- if( !verify_decoder( d ) ) return -1;+ if( !check_decoder( d ) ) return -1; return Lh_version( d->member_header ); } int LZ_decompress_dictionary_size( struct LZ_Decoder * const d ) {- if( !verify_decoder( d ) ) return -1;+ if( !check_decoder( d ) ) return -1; return Lh_get_dictionary_size( d->member_header ); } unsigned LZ_decompress_data_crc( struct LZ_Decoder * const d ) {- if( verify_decoder( d ) && d->lz_decoder )+ if( check_decoder( d ) && d->lz_decoder ) return LZd_crc( d->lz_decoder ); return 0; }@@ -572,7 +572,7 @@ unsigned long long LZ_decompress_data_position( struct LZ_Decoder * const d ) {- if( verify_decoder( d ) && d->lz_decoder )+ if( check_decoder( d ) && d->lz_decoder ) return LZd_data_position( d->lz_decoder ); return 0; }@@ -580,21 +580,21 @@ unsigned long long LZ_decompress_member_position( struct LZ_Decoder * const d ) {- if( !verify_decoder( d ) ) return 0;+ if( !check_decoder( d ) ) return 0; return d->rdec->member_position; } unsigned long long LZ_decompress_total_in_size( struct LZ_Decoder * const d ) {- if( !verify_decoder( d ) ) return 0;+ if( !check_decoder( d ) ) return 0; return d->partial_in_size + d->rdec->member_position; } unsigned long long LZ_decompress_total_out_size( struct LZ_Decoder * const d ) {- if( !verify_decoder( d ) ) return 0;+ if( !check_decoder( d ) ) return 0; if( d->lz_decoder ) return d->partial_out_size + LZd_data_position( d->lz_decoder ); return d->partial_out_size;
cbits/lzlib.h view
@@ -1,5 +1,5 @@ /* Lzlib - Compression library for the lzip format- Copyright (C) 2009-2022 Antonio Diaz Diaz.+ Copyright (C) 2009-2024 Antonio Diaz Diaz. This library is free software. Redistribution and use in source and binary forms, with or without modification, are permitted provided@@ -24,9 +24,9 @@ /* LZ_API_VERSION was first defined in lzlib 1.8 to 1. Since lzlib 1.12, LZ_API_VERSION is defined as (major * 1000 + minor). */ -#define LZ_API_VERSION 1013+#define LZ_API_VERSION 1014 -static const char * const LZ_version_string = "1.13";+static const char * const LZ_version_string = "1.14"; enum LZ_Errno { LZ_ok = 0, LZ_bad_argument, LZ_mem_error, LZ_sequence_error, LZ_header_error, LZ_unexpected_eof,
lzlib.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.18 name: lzlib-version: 1.0.7.2+version: 1.0.7.3 license: BSD3 license-file: LICENSE copyright: Copyright: (c) 2019-2021 Vanessa McHale@@ -14,7 +14,6 @@ category: Codec, Compression build-type: Simple extra-source-files:- stack.yaml cbits/cbuffer.c cbits/decoder.c cbits/decoder.h
− stack.yaml
@@ -1,7 +0,0 @@-----resolver: lts-14.18-ghc-options: {"$locals": -ddump-to-file -ddump-hi}-packages:- - '.'-extra-deps:- - pathological-bytestrings-0.1.0.0@sha256:0649a14d6e87091cc0f9e7430881e970e53008be262f878311b25d410ebf974b,1079
test/Spec.hs view
@@ -55,8 +55,7 @@ main :: IO () main = do ex' <- filterM doesFileExist ["gmp-6.1.2.tar.lz", "lzlib-1.10.tar.lz"]- ex <- ("test/data/7341e7190c2219dbc2641707c5c0e41e038f8a44.jpg" :)- . ("cbits/encoder.c" :)+ ex <- ("cbits/encoder.c" :) <$> filterM doesFileExist ["gmp-6.1.2.tar", "lzlib-1.10.tar"] hspec $ do describe "roundtrip" $