summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 13:34:28 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 13:34:28 +0000
commitbd57902c053fc6dfcfb477b465dd30c1db910c0e (patch)
tree128294bbf64ceb320138a1d9abb663500e9b49e1
parentAdding upstream version 0.4. (diff)
downloadlzlib-bd57902c053fc6dfcfb477b465dd30c1db910c0e.tar.xz
lzlib-bd57902c053fc6dfcfb477b465dd30c1db910c0e.zip
Adding upstream version 0.5.upstream/0.5
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
-rw-r--r--AUTHORS5
-rw-r--r--ChangeLog6
-rw-r--r--Makefile.in18
-rw-r--r--NEWS9
-rwxr-xr-xconfigure4
-rw-r--r--decoder.cc9
-rw-r--r--decoder.h19
-rw-r--r--doc/lzlib.info2
-rw-r--r--doc/lzlib.texinfo4
-rw-r--r--encoder.cc17
-rw-r--r--encoder.h8
-rw-r--r--lzlib.cc6
-rw-r--r--lzlib.h2
-rw-r--r--main.cc6
-rwxr-xr-xtestsuite/check.sh8
15 files changed, 64 insertions, 59 deletions
diff --git a/AUTHORS b/AUTHORS
index 576d9a1..6badf8e 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,5 +1,4 @@
Lzlib was written by Antonio Diaz Diaz.
-Lzlib implements a simplified version of the LZMA algorithm. The
-original LZMA algorithm was designed by Igor Pavlov.
-
+Lzlib implements a simplified version of the LZMA algorithm.
+The original LZMA algorithm was designed by Igor Pavlov.
diff --git a/ChangeLog b/ChangeLog
index d8ac767..b510dc0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-07-03 Antonio Diaz Diaz <ant_diaz@teleline.es>
+
+ * Version 0.5 released.
+ * Decompression speed has been improved.
+ * main.cc (signal_handler): Declared as `extern "C"'.
+
2009-06-03 Antonio Diaz Diaz <ant_diaz@teleline.es>
* Version 0.4 released.
diff --git a/Makefile.in b/Makefile.in
index 8c5f93c..1d05051 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -4,6 +4,7 @@ AR = ar
INSTALL = install
INSTALL_PROGRAM = $(INSTALL) -p -m 755
INSTALL_DATA = $(INSTALL) -p -m 644
+INSTALL_DIR = $(INSTALL) -d -m 755
LDCONFIG = ldconfig
SHELL = /bin/sh
@@ -79,8 +80,8 @@ check : all $(VPATH)/testsuite/check.sh
@$(VPATH)/testsuite/check.sh $(VPATH)/testsuite
install : all install-info
- if test ! -d $(DESTDIR)$(includedir) ; then $(INSTALL) -d $(DESTDIR)$(includedir) ; fi
- if test ! -d $(DESTDIR)$(libdir) ; then $(INSTALL) -d $(DESTDIR)$(libdir) ; fi
+ if test ! -d $(DESTDIR)$(includedir) ; then $(INSTALL_DIR) $(DESTDIR)$(includedir) ; fi
+ if test ! -d $(DESTDIR)$(libdir) ; then $(INSTALL_DIR) $(DESTDIR)$(libdir) ; fi
$(INSTALL_DATA) $(VPATH)/$(pkgname).h $(DESTDIR)$(includedir)/$(pkgname).h
$(INSTALL_DATA) ./$(libname).a $(DESTDIR)$(libdir)/$(libname).a
if test -n "$(progname_shared)" ; then \
@@ -94,10 +95,14 @@ install : all install-info
fi
install-info :
- if test ! -d $(DESTDIR)$(infodir) ; then $(INSTALL) -d $(DESTDIR)$(infodir) ; fi
+ if test ! -d $(DESTDIR)$(infodir) ; then $(INSTALL_DIR) $(DESTDIR)$(infodir) ; fi
$(INSTALL_DATA) $(VPATH)/doc/$(pkgname).info $(DESTDIR)$(infodir)/$(pkgname).info
-install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$(pkgname).info
+install-man :
+ if test ! -d $(DESTDIR)$(mandir)/man1 ; then $(INSTALL_DIR) $(DESTDIR)$(mandir)/man1 ; fi
+ $(INSTALL_DATA) $(VPATH)/doc/$(progname).1 $(DESTDIR)$(mandir)/man1/$(progname).1
+
install-strip : all
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
@@ -108,9 +113,12 @@ uninstall : uninstall-info
-rm -f $(DESTDIR)$(libdir)/$(libname).so.$(pkgversion)
uninstall-info :
- -install-info --remove $(DESTDIR)$(infodir)/$(pkgname).info $(DESTDIR)$(infodir)/dir
+ -install-info --info-dir=$(DESTDIR)$(infodir) --remove $(DESTDIR)$(infodir)/$(pkgname).info
-rm -f $(DESTDIR)$(infodir)/$(pkgname).info
+uninstall-man :
+ -rm -f $(DESTDIR)$(mandir)/man1/$(progname).1
+
dist :
ln -sf $(VPATH) $(DISTNAME)
tar -cvf $(DISTNAME).tar \
@@ -132,7 +140,7 @@ dist :
lzip -v -9 $(DISTNAME).tar
clean :
- -rm -f $(progname) $(progname)_profiled $(lib_objs) $(objs) *.a
+ -rm -f $(progname) $(progname)_profiled $(objs) $(lib_objs) *.a
-rm -f $(progname)_shared $(sh_lib_objs) *.so.$(pkgversion)
distclean : clean
diff --git a/NEWS b/NEWS
index f97bcd8..7a7df99 100644
--- a/NEWS
+++ b/NEWS
@@ -1,10 +1,5 @@
-Changes in version 0.4:
-
-Partial flush of the compressed data has been implemented with the
-function LZ_compress_sync_flush.
-
-The function LZ_compress_write_size has been added.
+Changes in version 0.5:
Decompression speed has been improved.
-The chapter "Buffering" has been added to the manual.
+A build problem with the Sun C++ compiler has been fixed.
diff --git a/configure b/configure
index ba2cad0..4255d2f 100755
--- a/configure
+++ b/configure
@@ -5,13 +5,13 @@
# This configure script is free software: you have unlimited permission
# to copy, distribute and modify it.
#
-# Date of this version: 2009-06-03
+# Date of this version: 2009-07-03
invocation_name=$0
args=
no_create=
pkgname=lzlib
-pkgversion=0.4
+pkgversion=0.5
soversion=0
progname=minilzip
progname_shared=${progname}_shared
diff --git a/decoder.cc b/decoder.cc
index f68edf9..b426b3e 100644
--- a/decoder.cc
+++ b/decoder.cc
@@ -130,12 +130,12 @@ int LZ_decoder::decode_member()
const int pos_state = data_position() & pos_state_mask;
if( range_decoder.decode_bit( bm_match[state()][pos_state] ) == 0 )
{
+ const uint8_t prev_byte = get_byte( 0 );
if( state.is_char() )
- prev_byte = literal_decoder.decode( range_decoder, prev_byte );
+ put_byte( literal_decoder.decode( range_decoder, prev_byte ) );
else
- prev_byte = literal_decoder.decode_matched( range_decoder, prev_byte,
- get_byte( rep0 ) );
- put_byte( prev_byte );
+ put_byte( literal_decoder.decode_matched( range_decoder, prev_byte,
+ get_byte( rep0 ) ) );
state.set_char();
}
else
@@ -209,7 +209,6 @@ int LZ_decoder::decode_member()
state.set_match();
}
copy_block( rep0, len );
- prev_byte = get_byte( 0 );
}
}
}
diff --git a/decoder.h b/decoder.h
index 6484898..bc9297a 100644
--- a/decoder.h
+++ b/decoder.h
@@ -91,9 +91,9 @@ public:
if( force ) reload_pending = true;
if( reload_pending && available_bytes() >= 5 )
{
+ reload_pending = false;
code = 0;
range = 0xFFFFFFFF;
- reload_pending = false;
for( int i = 0; i < 5; ++i ) code = (code << 8) | get_byte();
}
return !reload_pending;
@@ -216,11 +216,11 @@ class Literal_decoder
{ return ( prev_byte >> ( 8 - literal_context_bits ) ); }
public:
- uint8_t decode( Range_decoder & range_decoder, const int prev_byte )
+ uint8_t decode( Range_decoder & range_decoder, const uint8_t prev_byte )
{ return range_decoder.decode_tree( bm_literal[state(prev_byte)], 8 ); }
uint8_t decode_matched( Range_decoder & range_decoder,
- const int prev_byte, const int match_byte )
+ const uint8_t prev_byte, const uint8_t match_byte )
{ return range_decoder.decode_matched( bm_literal[state(prev_byte)], match_byte ); }
};
@@ -233,12 +233,11 @@ class LZ_decoder : public Circular_buffer
const int dictionary_size;
uint32_t crc_;
bool member_finished_;
- unsigned int rep0;
- unsigned int rep1;
- unsigned int rep2;
+ unsigned int rep0; // rep[0-3] latest four distances
+ unsigned int rep1; // used for efficient coding of
+ unsigned int rep2; // repeated distances
unsigned int rep3;
State state;
- uint8_t prev_byte;
Bit_model bm_match[State::states][pos_states];
Bit_model bm_rep[State::states];
@@ -273,7 +272,7 @@ class LZ_decoder : public Circular_buffer
{
int i = put - distance - 1;
if( i < 0 ) i += buffer_size;
- if( len < buffer_size - std::max( put, i ) && len <= distance )
+ if( len < buffer_size - std::max( put, i ) && len <= std::abs( put - i ) )
{
crc32.update( crc_, buffer + i, len );
std::memcpy( buffer + put, buffer + i, len );
@@ -303,9 +302,9 @@ public:
rep1( 0 ),
rep2( 0 ),
rep3( 0 ),
- prev_byte( 0 ),
range_decoder( sizeof header, ibuf ),
- literal_decoder() {}
+ literal_decoder()
+ { buffer[buffer_size-1] = 0; } // prev_byte of first_byte
bool enough_free_bytes() const throw()
{ return free_bytes() >= min_free_bytes; }
diff --git a/doc/lzlib.info b/doc/lzlib.info
index fff59c2..e688ea6 100644
--- a/doc/lzlib.info
+++ b/doc/lzlib.info
@@ -12,7 +12,7 @@ File: lzlib.info, Node: Top, Next: Introduction, Up: (dir)
Lzlib
*****
-This manual is for Lzlib (version 0.4, 3 June 2009).
+This manual is for Lzlib (version 0.5, 3 July 2009).
* Menu:
diff --git a/doc/lzlib.texinfo b/doc/lzlib.texinfo
index 044bd04..d0cdd2b 100644
--- a/doc/lzlib.texinfo
+++ b/doc/lzlib.texinfo
@@ -5,8 +5,8 @@
@finalout
@c %**end of header
-@set UPDATED 3 June 2009
-@set VERSION 0.4
+@set UPDATED 3 July 2009
+@set VERSION 0.5
@dircategory Data Compression
@direntry
diff --git a/encoder.cc b/encoder.cc
index cca154c..51ffb95 100644
--- a/encoder.cc
+++ b/encoder.cc
@@ -61,9 +61,8 @@ Matchfinder::Matchfinder( const int dict_size, const int len_limit )
:
partial_data_pos( 0 ),
dictionary_size_( dict_size ),
- after_size( max_num_trials + max_match_len ),
buffer_size( ( 2 * std::max( 65536, dictionary_size_ ) ) +
- max_num_trials + after_size ),
+ before_size + after_size ),
buffer( new( std::nothrow ) uint8_t[buffer_size] ),
pos( 0 ),
cyclic_pos( 0 ),
@@ -105,7 +104,7 @@ bool Matchfinder::move_pos() throw()
if( pos > stream_pos ) { pos = stream_pos; return false; }
else
{
- const int offset = pos - dictionary_size_ - max_num_trials;
+ const int offset = pos - dictionary_size_ - before_size;
const int size = stream_pos - offset;
std::memmove( buffer, buffer + offset, size );
partial_data_pos += offset;
@@ -457,7 +456,7 @@ int LZ_encoder::best_pair_sequence( const int reps[num_rep_distances],
}
- // Sync Flush mark => (dis == 0xFFFFFFFF, len == min_match_len+1)
+ // Sync Flush mark => (dis == 0xFFFFFFFF, len == min_match_len + 1)
bool LZ_encoder::sync_flush()
{
if( member_finished_ || range_encoder.free_bytes() < max_marker_size )
@@ -505,7 +504,6 @@ LZ_encoder::LZ_encoder( Matchfinder & mf, const File_header & header,
literal_encoder(),
num_dis_slots( 2 * File_header::real_bits( matchfinder.dictionary_size() - 1 ) ),
fill_counter( 0 ),
- prev_byte( 0 ),
member_finished_( false )
{
for( int i = 0; i < num_rep_distances; ++i ) rep_distances[i] = 0;
@@ -522,15 +520,15 @@ bool LZ_encoder::encode_member( const bool finish )
if( range_encoder.member_position() >= member_size_limit )
{ if( full_flush() ) { member_finished_ = true; } return true; }
- // copy first byte
+ // encode first byte
if( matchfinder.data_position() == 0 && !matchfinder.finished() )
{
if( matchfinder.available_bytes() < 4 && !matchfinder.at_stream_end() )
return true;
range_encoder.encode_bit( bm_match[state()][0], 0 );
+ const uint8_t prev_byte = 0;
const uint8_t cur_byte = matchfinder[0];
literal_encoder.encode( range_encoder, prev_byte, cur_byte );
- prev_byte = cur_byte;
crc32.update( crc_, cur_byte );
if( !move_pos( 1 ) ) return false;
}
@@ -560,16 +558,16 @@ bool LZ_encoder::encode_member( const bool finish )
range_encoder.encode_bit( bm_match[state()][pos_state], !bit );
if( bit )
{
+ const uint8_t prev_byte = matchfinder[-ahead-1];
const uint8_t cur_byte = matchfinder[-ahead];
if( state.is_char() )
literal_encoder.encode( range_encoder, prev_byte, cur_byte );
else
{
- const uint8_t match_byte = matchfinder[-rep_distances[0]-1-ahead];
+ const uint8_t match_byte = matchfinder[-ahead-rep_distances[0]-1];
literal_encoder.encode_matched( range_encoder, prev_byte, match_byte, cur_byte );
}
state.set_char();
- prev_byte = cur_byte;
}
else
{
@@ -600,7 +598,6 @@ bool LZ_encoder::encode_member( const bool finish )
encode_pair( dis - num_rep_distances, len, pos_state );
state.set_match();
}
- prev_byte = matchfinder[len-1-ahead];
}
for( int j = 0; j < len; ++j )
crc32.update( crc_, matchfinder[j-ahead] );
diff --git a/encoder.h b/encoder.h
index cdfd751..9583e4f 100644
--- a/encoder.h
+++ b/encoder.h
@@ -145,7 +145,11 @@ inline int price_matched( const Bit_model bm[], const int symbol,
class Matchfinder
{
- enum { num_prev_positions4 = 1 << 20,
+ enum { // bytes to keep in buffer before dictionary
+ before_size = max_num_trials + 1,
+ // bytes to keep in buffer after pos
+ after_size = max_num_trials + max_match_len,
+ num_prev_positions4 = 1 << 20,
num_prev_positions3 = 1 << 18,
num_prev_positions2 = 1 << 16,
num_prev_positions = num_prev_positions4 + num_prev_positions3 +
@@ -153,7 +157,6 @@ class Matchfinder
long long partial_data_pos;
const int dictionary_size_; // bytes to keep in buffer before pos
- const int after_size; // bytes to keep in buffer after pos
const int buffer_size;
uint8_t * const buffer;
int pos;
@@ -459,7 +462,6 @@ class LZ_encoder
int align_price_count;
int fill_counter;
State state;
- uint8_t prev_byte;
bool member_finished_;
void fill_align_prices() throw();
diff --git a/lzlib.cc b/lzlib.cc
index c64ed43..76212db 100644
--- a/lzlib.cc
+++ b/lzlib.cc
@@ -335,7 +335,7 @@ int LZ_decompress_read( void * const decoder, uint8_t * const buffer,
if( d.ibuf->used_bytes() < 5 + (int)sizeof( File_header ) )
{
if( !d.ibuf->at_stream_end() || d.ibuf->finished() ) return 0;
- d.ibuf->purge();
+ d.ibuf->purge(); // remove trailing garbage
d.lz_errno = LZ_header_error;
return -1;
}
@@ -346,12 +346,12 @@ int LZ_decompress_read( void * const decoder, uint8_t * const buffer,
header.dictionary_size() < min_dictionary_size ||
header.dictionary_size() > max_dictionary_size )
{
- d.ibuf->purge();
+ d.ibuf->purge(); // remove trailing garbage
d.lz_errno = LZ_header_error;
return -1;
}
try { d.lz_decoder = new LZ_decoder( header, *d.ibuf ); }
- catch( std::bad_alloc )
+ catch( std::bad_alloc ) // not enough free memory
{
d.ibuf->purge();
d.lz_decoder = 0;
diff --git a/lzlib.h b/lzlib.h
index f2ef9d3..7dc9aab 100644
--- a/lzlib.h
+++ b/lzlib.h
@@ -29,7 +29,7 @@
extern "C" {
#endif
-const char * const LZ_version_string = "0.4";
+const char * const LZ_version_string = "0.5";
enum { min_dictionary_bits = 12,
min_dictionary_size = 1 << min_dictionary_bits,
diff --git a/main.cc b/main.cc
index d9cf922..11ee21f 100644
--- a/main.cc
+++ b/main.cc
@@ -558,8 +558,8 @@ int decompress( const int inhandle, const Pretty_print & pp,
const LZ_errno lz_errno = LZ_decompress_errno( decoder );
if( lz_errno == LZ_header_error )
{
- if( LZ_decompress_total_out_size( decoder ) > 0 ) // trailing garbage
- break;
+ if( LZ_decompress_total_out_size( decoder ) > 0 )
+ break; // trailing garbage
pp( "error reading member header" );
return 1;
}
@@ -596,7 +596,7 @@ int decompress( const int inhandle, const Pretty_print & pp,
}
-void signal_handler( const int ) throw()
+extern "C" void signal_handler( int ) throw()
{
show_error( "Control-C or similar caught, quitting." );
cleanup_and_fail( 0 );
diff --git a/testsuite/check.sh b/testsuite/check.sh
index 4431864..2ce2ca5 100755
--- a/testsuite/check.sh
+++ b/testsuite/check.sh
@@ -28,7 +28,7 @@ fail=0
"${LZIP}" -cd "${testdir}"/COPYING.lz > copy || fail=1
cmp in copy || fail=1
-for i in 1 2 3 4 5 6 7 8 9; do
+for i in s4096 1 2 3 4 5 6 7 8 9; do
"${LZIP}" -k -$i in || fail=1
mv -f in.lz copy.lz || fail=1
echo -n "garbage" >> copy.lz || fail=1
@@ -37,7 +37,7 @@ for i in 1 2 3 4 5 6 7 8 9; do
echo -n .
done
-for i in 1 2 3 4 5 6 7 8 9; do
+for i in s4096 1 2 3 4 5 6 7 8 9; do
"${LZIP}" -c -$i in > out || fail=1
echo -n "g" >> out || fail=1
"${LZIP}" -cd out > copy || fail=1
@@ -45,14 +45,14 @@ for i in 1 2 3 4 5 6 7 8 9; do
echo -n .
done
-for i in 1 2 3 4 5 6 7 8 9; do
+for i in s4096 1 2 3 4 5 6 7 8 9; do
"${LZIP}" -c -$i < in > out || fail=1
"${LZIP}" -d < out > copy || fail=1
cmp in copy || fail=1
echo -n .
done
-for i in 1 2 3 4 5 6 7 8 9; do
+for i in s4096 1 2 3 4 5 6 7 8 9; do
"${LZIP}" -f -$i -o out < in || fail=1
"${LZIP}" -df -o copy < out.lz || fail=1
cmp in copy || fail=1