From d892e74a10fe6758f89af3c9af063dff5a8f99b2 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 21 Feb 2016 13:41:43 +0100 Subject: Merging upstream version 0.8. Signed-off-by: Daniel Baumann --- ChangeLog | 7 ++++++- INSTALL | 2 +- NEWS | 5 +++-- README | 2 +- configure | 10 +++++----- lzd.cc | 14 +++++++++----- testsuite/check.sh | 2 +- 7 files changed, 26 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1200ef9..3aaf64a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016-01-23 Antonio Diaz Diaz + + * Version 0.8 released. + * Documented that lzip does not use 'literal_pos_state_bits'. + 2015-07-07 Antonio Diaz Diaz * Version 0.7 released. @@ -33,7 +38,7 @@ * Version 0.1 released. -Copyright (C) 2013-2015 Antonio Diaz Diaz. +Copyright (C) 2013-2016 Antonio Diaz Diaz. This file is a collection of facts, and thus it is not copyrightable, but just in case, you have unlimited permission to copy, distribute and diff --git a/INSTALL b/INSTALL index 7260e4a..014ab3f 100644 --- a/INSTALL +++ b/INSTALL @@ -50,7 +50,7 @@ After running 'configure', you can run 'make' and 'make install' as explained above. -Copyright (C) 2013-2015 Antonio Diaz Diaz. +Copyright (C) 2013-2016 Antonio Diaz Diaz. This file is free documentation: you have unlimited permission to copy, distribute and modify it. diff --git a/NEWS b/NEWS index e58eb7f..57ca1b3 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,4 @@ -Changes in version 0.7: +Changes in version 0.8: -Minor changes. +It has been documented that lzip does not use the LZMA parameter +'literal_pos_state_bits'. diff --git a/README b/README index 55c1c52..ae73fc1 100644 --- a/README +++ b/README @@ -45,7 +45,7 @@ range encoding), and Igor Pavlov (for putting all the above together in LZMA). -Copyright (C) 2013-2015 Antonio Diaz Diaz. +Copyright (C) 2013-2016 Antonio Diaz Diaz. This file is free documentation: you have unlimited permission to copy, distribute and modify it. diff --git a/configure b/configure index 70ed8c3..83d3447 100755 --- a/configure +++ b/configure @@ -1,12 +1,12 @@ #! /bin/sh # configure script for Lzd - Educational decompressor for the lzip format -# Copyright (C) 2013-2015 Antonio Diaz Diaz. +# Copyright (C) 2013-2016 Antonio Diaz Diaz. # # This configure script is free software: you have unlimited permission # to copy, distribute and modify it. pkgname=lzd -pkgversion=0.7 +pkgversion=0.8 progname=lzd srctrigger=lzd.cc @@ -139,7 +139,7 @@ if [ -z "${no_create}" ] ; then rm -f config.status cat > config.status << EOF #! /bin/sh -# This file was generated automatically by configure. Do not edit. +# This file was generated automatically by configure. Don't edit. # Run this file to recreate the current configuration. # # This script is free software: you have unlimited permission @@ -165,8 +165,8 @@ echo "LDFLAGS = ${LDFLAGS}" rm -f Makefile cat > Makefile << EOF # Makefile for Lzd - Educational decompressor for the lzip format -# Copyright (C) 2013-2015 Antonio Diaz Diaz. -# This file was generated automatically by configure. Do not edit. +# Copyright (C) 2013-2016 Antonio Diaz Diaz. +# This file was generated automatically by configure. Don't edit. # # This Makefile is free software: you have unlimited permission # to copy, distribute and modify it. diff --git a/lzd.cc b/lzd.cc index 30dde48..5f8dcdc 100644 --- a/lzd.cc +++ b/lzd.cc @@ -1,5 +1,5 @@ /* Lzd - Educational decompressor for the lzip format - Copyright (C) 2013-2015 Antonio Diaz Diaz. + Copyright (C) 2013-2016 Antonio Diaz Diaz. This program is free software: you have unlimited permission to copy, distribute and modify it. @@ -52,6 +52,7 @@ enum { min_dictionary_size = 1 << 12, max_dictionary_size = 1 << 29, literal_context_bits = 3, + literal_pos_state_bits = 0, // not used pos_state_bits = 2, pos_states = 1 << pos_state_bits, pos_state_mask = pos_states - 1, @@ -238,6 +239,7 @@ class LZ_decoder unsigned pos; // current pos in buffer unsigned stream_pos; // first byte not yet written to stdout uint32_t crc_; + bool pos_wrapped; void flush_data(); @@ -262,7 +264,8 @@ public: buffer( new uint8_t[dictionary_size] ), pos( 0 ), stream_pos( 0 ), - crc_( 0xFFFFFFFFU ) + crc_( 0xFFFFFFFFU ), + pos_wrapped( false ) { buffer[dictionary_size-1] = 0; } // prev_byte of first byte ~LZ_decoder() { delete[] buffer; } @@ -284,7 +287,8 @@ void LZ_decoder::flush_data() if( std::fwrite( buffer + stream_pos, 1, size, stdout ) != size ) { std::fprintf( stderr, "Write error: %s\n", std::strerror( errno ) ); std::exit( 1 ); } - if( pos >= dictionary_size ) { partial_data_pos += pos; pos = 0; } + if( pos >= dictionary_size ) + { partial_data_pos += pos; pos = 0; pos_wrapped = true; } stream_pos = pos; } } @@ -380,7 +384,7 @@ bool LZ_decoder::decode_member() // Returns false if error } } state.set_match(); - if( rep0 >= dictionary_size || rep0 >= data_position() ) + if( rep0 >= dictionary_size || ( rep0 >= pos && !pos_wrapped ) ) { flush_data(); return false; } } for( int i = 0; i < len; ++i ) put_byte( peek( rep0 ) ); @@ -402,7 +406,7 @@ int main( const int argc, const char * const argv[] ) "It is not safe to use lzd for any real work.\n" "\nUsage: %s < file.lz > file\n", argv[0] ); std::printf( "Lzd decompresses from standard input to standard output.\n" - "\nCopyright (C) 2015 Antonio Diaz Diaz.\n" + "\nCopyright (C) 2016 Antonio Diaz Diaz.\n" "This is free software: you are free to change and redistribute it.\n" "There is NO WARRANTY, to the extent permitted by law.\n" "Report bugs to lzip-bug@nongnu.org\n" diff --git a/testsuite/check.sh b/testsuite/check.sh index cf0a940..7ebec69 100755 --- a/testsuite/check.sh +++ b/testsuite/check.sh @@ -1,6 +1,6 @@ #! /bin/sh # check script for Lzd - Educational decompressor for lzip files -# Copyright (C) 2013-2015 Antonio Diaz Diaz. +# Copyright (C) 2013-2016 Antonio Diaz Diaz. # # This script is free software: you have unlimited permission # to copy, distribute and modify it. -- cgit v1.2.3