1
0
Fork 0

Merging upstream version 0.6.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-20 14:45:15 +01:00
parent 019c4bb60f
commit 4ddc7a24ed
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
10 changed files with 678 additions and 650 deletions

View file

@ -1,3 +1,8 @@
2014-08-25 Antonio Diaz Diaz <antonio@gnu.org>
* Version 0.6 released.
* Minor changes.
2013-09-17 Antonio Diaz Diaz <antonio@gnu.org> 2013-09-17 Antonio Diaz Diaz <antonio@gnu.org>
* Version 0.5 released. * Version 0.5 released.
@ -23,7 +28,7 @@
* Version 0.1 released. * Version 0.1 released.
Copyright (C) 2013 Antonio Diaz Diaz. Copyright (C) 2013, 2014 Antonio Diaz Diaz.
This file is a collection of facts, and thus it is not copyrightable, 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 but just in case, you have unlimited permission to copy, distribute and

18
INSTALL
View file

@ -1,7 +1,7 @@
Requirements Requirements
------------ ------------
You will need a C++ compiler. You will need a C++ compiler.
I use gcc 4.8.1 and 3.3.6, but the code should compile with any I use gcc 4.9.1 and 3.3.6, but the code should compile with any
standards compliant compiler. standards compliant compiler.
Gcc is available at http://gcc.gnu.org. Gcc is available at http://gcc.gnu.org.
@ -32,19 +32,19 @@ the main archive.
5. Type 'make install' to install the program and any data files and 5. Type 'make install' to install the program and any data files and
documentation. documentation.
You can install only the program, the info manual or the man page You can install only the program, the info manual or the man page by
typing 'make install-bin', 'make install-info' or 'make install-man' typing 'make install-bin', 'make install-info' or 'make install-man'
respectively. respectively.
Another way Another way
----------- -----------
You can also compile lzd into a separate directory. To do this, you You can also compile lzd into a separate directory.
must use a version of 'make' that supports the 'VPATH' variable, such To do this, you must use a version of 'make' that supports the 'VPATH'
as GNU 'make'. 'cd' to the directory where you want the object files variable, such as GNU 'make'. 'cd' to the directory where you want the
and executables to go and run the 'configure' script. 'configure' object files and executables to go and run the 'configure' script.
automatically checks for the source code in '.', in '..' and in the 'configure' automatically checks for the source code in '.', in '..' and
directory that 'configure' is in. in the directory that 'configure' is in.
'configure' recognizes the option '--srcdir=DIR' to control where to 'configure' recognizes the option '--srcdir=DIR' to control where to
look for the sources. Usually 'configure' can determine that directory look for the sources. Usually 'configure' can determine that directory
@ -54,7 +54,7 @@ After running 'configure', you can run 'make' and 'make install' as
explained above. explained above.
Copyright (C) 2013 Antonio Diaz Diaz. Copyright (C) 2013, 2014 Antonio Diaz Diaz.
This file is free documentation: you have unlimited permission to copy, This file is free documentation: you have unlimited permission to copy,
distribute and modify it. distribute and modify it.

View file

@ -1,8 +1,8 @@
DISTNAME = $(pkgname)-$(pkgversion) DISTNAME = $(pkgname)-$(pkgversion)
INSTALL = install INSTALL = install
INSTALL_PROGRAM = $(INSTALL) -p -m 755 INSTALL_PROGRAM = $(INSTALL) -m 755
INSTALL_DATA = $(INSTALL) -p -m 644 INSTALL_DATA = $(INSTALL) -m 644
INSTALL_DIR = $(INSTALL) -d -m 755 INSTALL_DIR = $(INSTALL) -d -m 755
SHELL = /bin/sh SHELL = /bin/sh
@ -16,13 +16,13 @@ objs = lzd.o
all : $(progname) all : $(progname)
$(progname) : $(objs) $(progname) : $(objs)
$(CXX) $(LDFLAGS) -o $@ $(objs) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(objs)
$(progname)_profiled : $(objs) $(progname)_profiled : $(objs)
$(CXX) $(LDFLAGS) -pg -o $@ $(objs) $(CXX) $(CXXFLAGS) $(LDFLAGS) -pg -o $@ $(objs)
%.o : %.cc %.o : %.cc
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -DPROGVERSION=\"$(pkgversion)\" -c -o $@ $< $(CXX) $(CXXFLAGS) $(CPPFLAGS) -DPROGVERSION=\"$(pkgversion)\" -c -o $@ $<
$(objs) : Makefile $(objs) : Makefile
@ -31,8 +31,8 @@ doc :
info : $(VPATH)/doc/$(pkgname).info info : $(VPATH)/doc/$(pkgname).info
$(VPATH)/doc/$(pkgname).info : $(VPATH)/doc/$(pkgname).texinfo $(VPATH)/doc/$(pkgname).info : $(VPATH)/doc/$(pkgname).texi
cd $(VPATH)/doc && makeinfo $(pkgname).texinfo cd $(VPATH)/doc && makeinfo $(pkgname).texi
man : $(VPATH)/doc/$(progname).1 man : $(VPATH)/doc/$(progname).1
@ -78,7 +78,7 @@ uninstall-man :
dist : doc dist : doc
ln -sf $(VPATH) $(DISTNAME) ln -sf $(VPATH) $(DISTNAME)
tar -cvf $(DISTNAME).tar \ tar -Hustar --owner=root --group=root -cvf $(DISTNAME).tar \
$(DISTNAME)/AUTHORS \ $(DISTNAME)/AUTHORS \
$(DISTNAME)/ChangeLog \ $(DISTNAME)/ChangeLog \
$(DISTNAME)/INSTALL \ $(DISTNAME)/INSTALL \

2
NEWS
View file

@ -1,3 +1,3 @@
Changes in version 0.5: Changes in version 0.6:
Minor changes. Minor changes.

26
README
View file

@ -13,6 +13,30 @@ correctly decompress the concatenation of two or more compressed files.
The result is the concatenation of the corresponding decompressed data. The result is the concatenation of the corresponding decompressed data.
Integrity of such concatenated compressed input is also verified. Integrity of such concatenated compressed input is also verified.
The lzip file format is designed for long-term data archiving, taking
into account both data integrity and decoder availability:
* The lzip format provides very safe integrity checking and some data
recovery means. The lziprecover program can repair bit-flip errors
(one of the most common forms of data corruption) in lzip files,
and provides data recovery capabilities, including error-checked
merging of damaged copies of a file.
* The lzip format is as simple as possible (but not simpler). The
lzip manual provides the code of a simple decompressor along with a
detailed explanation of how it works, so that with the only help of
the lzip manual it would be possible for a digital archaeologist to
extract the data from a lzip file long after quantum computers
eventually render LZMA obsolete.
* Additionally lzip is copylefted, which guarantees that it will
remain free forever.
A nice feature of the lzip format is that a corrupt byte is easier to
repair the nearer it is from the beginning of the file. Therefore, with
the help of lziprecover, losing an entire archive just because of a
corrupt byte near the beginning is a thing of the past.
The ideas embodied in lzd are due to (at least) the following people: The ideas embodied in lzd are due to (at least) the following people:
Abraham Lempel and Jacob Ziv (for the LZ algorithm), Andrey Markov (for Abraham Lempel and Jacob Ziv (for the LZ algorithm), Andrey Markov (for
the definition of Markov chains), G.N.N. Martin (for the definition of the definition of Markov chains), G.N.N. Martin (for the definition of
@ -20,7 +44,7 @@ range encoding), and Igor Pavlov (for putting all the above together in
LZMA). LZMA).
Copyright (C) 2013 Antonio Diaz Diaz. Copyright (C) 2013, 2014 Antonio Diaz Diaz.
This file is free documentation: you have unlimited permission to copy, This file is free documentation: you have unlimited permission to copy,
distribute and modify it. distribute and modify it.

8
configure vendored
View file

@ -1,12 +1,12 @@
#! /bin/sh #! /bin/sh
# configure script for Lzd - Educational decompressor for lzip files # configure script for Lzd - Educational decompressor for lzip files
# Copyright (C) 2013 Antonio Diaz Diaz. # Copyright (C) 2013, 2014 Antonio Diaz Diaz.
# #
# This configure script is free software: you have unlimited permission # This configure script is free software: you have unlimited permission
# to copy, distribute and modify it. # to copy, distribute and modify it.
pkgname=lzd pkgname=lzd
pkgversion=0.5 pkgversion=0.6
progname=lzd progname=lzd
srctrigger=lzd.cc srctrigger=lzd.cc
@ -64,7 +64,7 @@ while [ $# != 0 ] ; do
echo " --datarootdir=DIR base directory for doc and data [${datarootdir}]" echo " --datarootdir=DIR base directory for doc and data [${datarootdir}]"
echo " --infodir=DIR info files directory [${infodir}]" echo " --infodir=DIR info files directory [${infodir}]"
echo " --mandir=DIR man pages directory [${mandir}]" echo " --mandir=DIR man pages directory [${mandir}]"
echo " CXX=COMPILER C++ compiler to use [g++]" echo " CXX=COMPILER C++ compiler to use [${CXX}]"
echo " CPPFLAGS=OPTIONS command line options for the preprocessor [${CPPFLAGS}]" echo " CPPFLAGS=OPTIONS command line options for the preprocessor [${CPPFLAGS}]"
echo " CXXFLAGS=OPTIONS command line options for the C++ compiler [${CXXFLAGS}]" echo " CXXFLAGS=OPTIONS command line options for the C++ compiler [${CXXFLAGS}]"
echo " LDFLAGS=OPTIONS command line options for the linker [${LDFLAGS}]" echo " LDFLAGS=OPTIONS command line options for the linker [${LDFLAGS}]"
@ -165,7 +165,7 @@ echo "LDFLAGS = ${LDFLAGS}"
rm -f Makefile rm -f Makefile
cat > Makefile << EOF cat > Makefile << EOF
# Makefile for Lzd - Educational decompressor for lzip files # Makefile for Lzd - Educational decompressor for lzip files
# Copyright (C) 2013 Antonio Diaz Diaz. # Copyright (C) 2013, 2014 Antonio Diaz Diaz.
# This file was generated automatically by configure. Do not edit. # This file was generated automatically by configure. Do not edit.
# #
# This Makefile is free software: you have unlimited permission # This Makefile is free software: you have unlimited permission

31
lzd.cc
View file

@ -1,5 +1,5 @@
/* Lzd - Educational decompressor for lzip files /* Lzd - Educational decompressor for lzip files
Copyright (C) 2013 Antonio Diaz Diaz. Copyright (C) 2013, 2014 Antonio Diaz Diaz.
This program is free software: you have unlimited permission This program is free software: you have unlimited permission
to copy, distribute and modify it. to copy, distribute and modify it.
@ -21,7 +21,7 @@
#include <cstring> #include <cstring>
#include <stdint.h> #include <stdint.h>
#include <unistd.h> #include <unistd.h>
#if defined(__MSVCRT__) || defined(__OS2__) #if defined(__MSVCRT__) || defined(__OS2__) || defined(_MSC_VER)
#include <fcntl.h> #include <fcntl.h>
#include <io.h> #include <io.h>
#endif #endif
@ -213,7 +213,7 @@ public:
break; break;
} }
} }
return symbol - 0x100; return symbol & 0xFF;
} }
int decode_len( Len_model & lm, const int pos_state ) int decode_len( Len_model & lm, const int pos_state )
@ -263,7 +263,7 @@ public:
pos( 0 ), pos( 0 ),
stream_pos( 0 ), stream_pos( 0 ),
crc_( 0xFFFFFFFFU ) crc_( 0xFFFFFFFFU )
{ buffer[dictionary_size-1] = 0; } // prev_byte of first_byte { buffer[dictionary_size-1] = 0; } // prev_byte of first byte
~LZ_decoder() { delete[] buffer; } ~LZ_decoder() { delete[] buffer; }
@ -282,7 +282,7 @@ void LZ_decoder::flush_data()
crc32.update_buf( crc_, buffer + stream_pos, size ); crc32.update_buf( crc_, buffer + stream_pos, size );
errno = 0; errno = 0;
if( std::fwrite( buffer + stream_pos, 1, size, stdout ) != size ) if( std::fwrite( buffer + stream_pos, 1, size, stdout ) != size )
{ std::fprintf( stderr, "Write error: %s\n", std::strerror( errno ) ); { std::fprintf( stderr, "Write error: %s.\n", std::strerror( errno ) );
std::exit( 1 ); } std::exit( 1 ); }
if( pos >= dictionary_size ) { partial_data_pos += pos; pos = 0; } if( pos >= dictionary_size ) { partial_data_pos += pos; pos = 0; }
stream_pos = pos; stream_pos = pos;
@ -380,13 +380,13 @@ bool LZ_decoder::decode_member() // Returns false if error
} }
} }
state.set_match(); state.set_match();
if( rep0 >= dictionary_size || ( rep0 >= pos && !partial_data_pos ) ) if( rep0 >= dictionary_size || rep0 >= data_position() )
return false; { flush_data(); return false; }
} }
for( int i = 0; i < len; ++i ) for( int i = 0; i < len; ++i ) put_byte( get_byte( rep0 ) );
put_byte( get_byte( rep0 ) );
} }
} }
flush_data();
return false; return false;
} }
@ -402,7 +402,7 @@ int main( const int argc, const char * const argv[] )
"It is not safe to use lzd for any real work.\n" "It is not safe to use lzd for any real work.\n"
"\nUsage: %s < file.lz > file\n", argv[0] ); "\nUsage: %s < file.lz > file\n", argv[0] );
std::printf( "Lzd decompresses from standard input to standard output.\n" std::printf( "Lzd decompresses from standard input to standard output.\n"
"\nCopyright (C) 2013 Antonio Diaz Diaz.\n" "\nCopyright (C) 2014 Antonio Diaz Diaz.\n"
"This is free software: you are free to change and redistribute it.\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" "There is NO WARRANTY, to the extent permitted by law.\n"
"Report bugs to lzip-bug@nongnu.org\n" "Report bugs to lzip-bug@nongnu.org\n"
@ -410,16 +410,15 @@ int main( const int argc, const char * const argv[] )
return 0; return 0;
} }
#if defined(__MSVCRT__) || defined(__OS2__) #if defined(__MSVCRT__) || defined(__OS2__) || defined(_MSC_VER)
setmode( STDIN_FILENO, O_BINARY ); setmode( fileno( stdin ), O_BINARY );
setmode( STDOUT_FILENO, O_BINARY ); setmode( fileno( stdout ), O_BINARY );
#endif #endif
for( bool first_member = true; ; first_member = false ) for( bool first_member = true; ; first_member = false )
{ {
File_header header; File_header header;
for( int i = 0; i < 6; ++i ) for( int i = 0; i < 6; ++i ) header[i] = std::getc( stdin );
header[i] = std::getc( stdin );
if( std::feof( stdin ) || std::memcmp( header, "LZIP", 4 ) != 0 ) if( std::feof( stdin ) || std::memcmp( header, "LZIP", 4 ) != 0 )
{ {
if( first_member ) if( first_member )
@ -454,7 +453,7 @@ int main( const int argc, const char * const argv[] )
} }
if( std::fclose( stdout ) != 0 ) if( std::fclose( stdout ) != 0 )
{ std::fprintf( stderr, "Can't close stdout: %s\n", std::strerror( errno ) ); { std::fprintf( stderr, "Can't close stdout: %s.\n", std::strerror( errno ) );
return 1; } return 1; }
return 0; return 0;
} }

View file

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# check script for Lzd - Educational decompressor for lzip files # check script for Lzd - Educational decompressor for lzip files
# Copyright (C) 2013 Antonio Diaz Diaz. # Copyright (C) 2013, 2014 Antonio Diaz Diaz.
# #
# This script is free software: you have unlimited permission # This script is free software: you have unlimited permission
# to copy, distribute and modify it. # to copy, distribute and modify it.
@ -12,7 +12,7 @@ testdir=`cd "$1" ; pwd`
LZIP="${objdir}"/lzd LZIP="${objdir}"/lzd
framework_failure() { echo "failure in testing framework" ; exit 1 ; } framework_failure() { echo "failure in testing framework" ; exit 1 ; }
if [ ! -x "${LZIP}" ] ; then if [ ! -f "${LZIP}" ] || [ ! -x "${LZIP}" ] ; then
echo "${LZIP}: cannot execute" echo "${LZIP}: cannot execute"
exit 1 exit 1
fi fi
@ -28,10 +28,10 @@ fail=0
printf "testing lzd-%s..." "$2" printf "testing lzd-%s..." "$2"
"${LZIP}" < "${in}" 2> /dev/null "${LZIP}" < "${in}" 2> /dev/null
if [ $? = 2 ] ; then printf . ; else fail=1 ; printf - ; fi if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
dd if="${in_lz}" bs=1 count=6 2> /dev/null | "${LZIP}" 2> /dev/null dd if="${in_lz}" bs=1 count=6 2> /dev/null | "${LZIP}" 2> /dev/null
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
dd if="${in_lz}" bs=1 count=20 2> /dev/null | "${LZIP}" 2> /dev/null dd if="${in_lz}" bs=1 count=20 2> /dev/null | "${LZIP}" > /dev/null 2>&1
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
"${LZIP}" < "${in_lz}" > copy || fail=1 "${LZIP}" < "${in_lz}" > copy || fail=1

File diff suppressed because it is too large Load diff

Binary file not shown.