summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-05 18:38:04 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-05 18:38:16 +0000
commit3687e1b490ffcc6b4ec40c3474c4ba9f21fccb18 (patch)
treeaf854df24c50005641f16c308d3b0fd995831c29
parentReleasing debian version 1.2-7. (diff)
downloadlzd-3687e1b490ffcc6b4ec40c3474c4ba9f21fccb18.tar.xz
lzd-3687e1b490ffcc6b4ec40c3474c4ba9f21fccb18.zip
Merging upstream version 1.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
-rw-r--r--AUTHORS2
-rw-r--r--ChangeLog9
-rw-r--r--INSTALL15
-rw-r--r--Makefile.in2
-rw-r--r--NEWS19
-rw-r--r--README18
-rwxr-xr-xconfigure12
-rw-r--r--lzd.cc21
-rwxr-xr-xtestsuite/check.sh15
9 files changed, 55 insertions, 58 deletions
diff --git a/AUTHORS b/AUTHORS
index 27ceba5..48f7099 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,6 +1,6 @@
Lzd was written by Antonio Diaz Diaz.
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 the
+Abraham Lempel and Jacob Ziv (for the LZ algorithm), Andrei Markov (for the
definition of Markov chains), G.N.N. Martin (for the definition of range
encoding), and Igor Pavlov (for putting all the above together in LZMA).
diff --git a/ChangeLog b/ChangeLog
index b17c9db..042b251 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2022-10-24 Antonio Diaz Diaz <antonio@gnu.org>
+
+ * Version 1.3 released.
+ * lzd.cc (Range_decoder): Discard first byte explicitly.
+
2021-01-04 Antonio Diaz Diaz <antonio@gnu.org>
* Version 1.2 released.
@@ -12,7 +17,7 @@
* Version 1.1 released.
* Rename File_* to Lzip_*.
* lzd.cc: Compile on DOS with DJGPP.
- * configure: Accept appending to CXXFLAGS, 'CXXFLAGS+=OPTIONS'.
+ * configure: Accept appending to CXXFLAGS; 'CXXFLAGS+=OPTIONS'.
2017-05-02 Antonio Diaz Diaz <antonio@gnu.org>
@@ -65,7 +70,7 @@
* Version 0.1 released.
-Copyright (C) 2013-2021 Antonio Diaz Diaz.
+Copyright (C) 2013-2022 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 f2a5025..ecf03f1 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,7 +1,8 @@
Requirements
------------
-You will need a C++11 compiler. (gcc 3.3.6 or newer is recommended).
-I use gcc 6.1.0 and 4.1.2, but the code should compile with any standards
+You will need a C++98 compiler with support for 'long long'.
+(gcc 3.3.6 or newer is recommended).
+I use gcc 6.1.0 and 3.3.6, but the code should compile with any standards
compliant compiler.
Gcc is available at http://gcc.gnu.org.
@@ -14,8 +15,8 @@ Procedure
or
lzip -cd lzd[version].tar.lz | tar -xf -
-This creates the directory ./lzd[version] containing the source from
-the main archive.
+This creates the directory ./lzd[version] containing the source code
+extracted from the archive.
2. Change to lzd directory and run configure.
(Try 'configure --help' for usage instructions).
@@ -42,15 +43,15 @@ object files and executables to go and run the 'configure' script.
'configure' automatically checks for the source code in '.', in '..', and
in the directory that 'configure' is in.
-'configure' recognizes the option '--srcdir=DIR' to control where to
-look for the sources. Usually 'configure' can determine that directory
+'configure' recognizes the option '--srcdir=DIR' to control where to look
+for the source code. Usually 'configure' can determine that directory
automatically.
After running 'configure', you can run 'make' and 'make install' as
explained above.
-Copyright (C) 2013-2021 Antonio Diaz Diaz.
+Copyright (C) 2013-2022 Antonio Diaz Diaz.
This file is free documentation: you have unlimited permission to copy,
distribute, and modify it.
diff --git a/Makefile.in b/Makefile.in
index b2f6d55..ced714d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -19,7 +19,7 @@ objs = lzd.o
all : $(progname)
$(progname) : $(objs)
- $(CXX) $(LDFLAGS) $(CXXFLAGS) -o $@ $(objs)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(objs)
%.o : %.cc
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -DPROGVERSION=\"$(pkgversion)\" -c -o $@ $<
diff --git a/NEWS b/NEWS
index f1893b8..2416499 100644
--- a/NEWS
+++ b/NEWS
@@ -1,16 +1,5 @@
-Changes in version 1.2:
+Changes in version 1.3:
-Mismatches in member size are now verified. Lzd is now compliant with the
-lzip specification; it verifies the 3 integrity factors.
-
-Lzd now accepts (and ignores) the option '-d'. This allows it to be used as
-argument to the option '--lz' of the tools from the zutils package.
-
-The warning about "lzd not safe for real work" has been removed.
-(Lzd is safe, just not very convenient to use).
-
-10 new test files have been added to the testsuite.
-
-The source code of lzd is now used as a reference in the description of the
-media type 'application/lzip'.
-See http://datatracker.ietf.org/doc/draft-diaz-lzip
+Lzd now discards the first byte of the LZMA stream explicity (instead of
+shifting 1 extra byte in the initialization of 'code') to make the intent
+clearer.
diff --git a/README b/README
index fa5ff44..fae23bc 100644
--- a/README
+++ b/README
@@ -1,15 +1,15 @@
Description
Lzd is a simplified decompressor for the lzip format with an educational
-purpose. Studying its source is a good first step to understand how lzip
-works.
+purpose. Studying its source code is a good first step to understand how
+lzip works. Lzd is written in C++.
-The source of lzd is used in the lzip manual as a reference decompressor in
-the description of the lzip file format. Reading the lzip manual will help
-you understand the source. Lzd is compliant with the lzip specification; it
-verifies the 3 integrity factors.
+The source code of lzd is used in the lzip manual as a reference
+decompressor in the description of the lzip file format. Reading the lzip
+manual will help you understand the source code. Lzd is compliant with the
+lzip specification; it verifies the 3 integrity factors.
-The source of lzd is also used as a reference in the description of the
+The source code of lzd is also used as a reference in the description of the
media type 'application/lzip'.
See http://datatracker.ietf.org/doc/draft-diaz-lzip
@@ -47,12 +47,12 @@ 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:
-Abraham Lempel and Jacob Ziv (for the LZ algorithm), Andrey Markov (for the
+Abraham Lempel and Jacob Ziv (for the LZ algorithm), Andrei Markov (for the
definition of Markov chains), G.N.N. Martin (for the definition of range
encoding), and Igor Pavlov (for putting all the above together in LZMA).
-Copyright (C) 2013-2021 Antonio Diaz Diaz.
+Copyright (C) 2013-2022 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 a1f7471..cf10b79 100755
--- a/configure
+++ b/configure
@@ -1,12 +1,12 @@
#! /bin/sh
# configure script for Lzd - Educational decompressor for the lzip format
-# Copyright (C) 2013-2021 Antonio Diaz Diaz.
+# Copyright (C) 2013-2022 Antonio Diaz Diaz.
#
# This configure script is free software: you have unlimited permission
# to copy, distribute, and modify it.
pkgname=lzd
-pkgversion=1.2
+pkgversion=1.3
progname=lzd
srctrigger=lzd.cc
@@ -57,7 +57,7 @@ while [ $# != 0 ] ; do
echo "Options and variables: [defaults in brackets]"
echo " -h, --help display this help and exit"
echo " -V, --version output version information and exit"
- echo " --srcdir=DIR find the sources in DIR [. or ..]"
+ echo " --srcdir=DIR find the source code in DIR [. or ..]"
echo " --prefix=DIR install into DIR [${prefix}]"
echo " --exec-prefix=DIR base directory for arch-dependent files [${exec_prefix}]"
echo " --bindir=DIR user executables directory [${bindir}]"
@@ -115,7 +115,7 @@ while [ $# != 0 ] ; do
fi
done
-# Find the source files, if location was not specified.
+# Find the source code, if location was not specified.
srcdirtext=
if [ -z "${srcdir}" ] ; then
srcdirtext="or . or .." ; srcdir=.
@@ -127,7 +127,7 @@ if [ -z "${srcdir}" ] ; then
fi
if [ ! -r "${srcdir}/${srctrigger}" ] ; then
- echo "configure: Can't find sources in ${srcdir} ${srcdirtext}" 1>&2
+ echo "configure: Can't find source code in ${srcdir} ${srcdirtext}" 1>&2
echo "configure: (At least ${srctrigger} is missing)." 1>&2
exit 1
fi
@@ -167,7 +167,7 @@ echo "LDFLAGS = ${LDFLAGS}"
rm -f Makefile
cat > Makefile << EOF
# Makefile for Lzd - Educational decompressor for the lzip format
-# Copyright (C) 2013-2021 Antonio Diaz Diaz.
+# Copyright (C) 2013-2022 Antonio Diaz Diaz.
# This file was generated automatically by configure. Don't edit.
#
# This Makefile is free software: you have unlimited permission
diff --git a/lzd.cc b/lzd.cc
index f7572b2..9e1c3b8 100644
--- a/lzd.cc
+++ b/lzd.cc
@@ -1,5 +1,5 @@
/* Lzd - Educational decompressor for the lzip format
- Copyright (C) 2013-2021 Antonio Diaz Diaz.
+ Copyright (C) 2013-2022 Antonio Diaz Diaz.
This program is free software. Redistribution and use in source and
binary forms, with or without modification, are permitted provided
@@ -18,8 +18,8 @@
*/
/*
Exit status: 0 for a normal exit, 1 for environmental problems
- (file not found, invalid flags, I/O errors, etc), 2 to indicate a
- corrupt or invalid input file.
+ (file not found, invalid command line options, I/O errors, etc), 2 to
+ indicate a corrupt or invalid input file.
*/
#include <algorithm>
@@ -29,7 +29,7 @@
#include <cstring>
#include <stdint.h>
#include <unistd.h>
-#if defined(__MSVCRT__) || defined(__OS2__) || defined(__DJGPP__)
+#if defined __MSVCRT__ || defined __OS2__ || defined __DJGPP__
#include <fcntl.h>
#include <io.h>
#endif
@@ -147,7 +147,8 @@ class Range_decoder
public:
Range_decoder() : member_pos( 6 ), code( 0 ), range( 0xFFFFFFFFU )
{
- for( int i = 0; i < 5; ++i ) code = ( code << 8 ) | get_byte();
+ get_byte(); // discard first byte of the LZMA stream
+ for( int i = 0; i < 4; ++i ) code = ( code << 8 ) | get_byte();
}
uint8_t get_byte() { ++member_pos; return std::getc( stdin ); }
@@ -180,8 +181,8 @@ public:
}
else
{
- range -= bound;
code -= bound;
+ range -= bound;
bm.probability -= bm.probability >> bit_model_move_bits;
symbol = 1;
}
@@ -308,7 +309,7 @@ void LZ_decoder::flush_data()
}
-bool LZ_decoder::decode_member() // Returns false if error
+bool LZ_decoder::decode_member() // Return false if error
{
Bit_model bm_literal[1<<literal_context_bits][0x300];
Bit_model bm_match[State::states][pos_states];
@@ -415,11 +416,11 @@ int main( const int argc, const char * const argv[] )
{
std::printf(
"Lzd %s - Educational decompressor for the lzip format.\n"
- "Study the source to learn how a lzip decompressor works.\n"
+ "Study the source code to learn how a lzip decompressor works.\n"
"See the lzip manual for an explanation of the code.\n"
"\nUsage: %s [-d] < file.lz > file\n"
"Lzd decompresses from standard input to standard output.\n"
- "\nCopyright (C) 2021 Antonio Diaz Diaz.\n"
+ "\nCopyright (C) 2022 Antonio Diaz Diaz.\n"
"License 2-clause BSD.\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"
@@ -429,7 +430,7 @@ int main( const int argc, const char * const argv[] )
return 0;
}
-#if defined(__MSVCRT__) || defined(__OS2__) || defined(__DJGPP__)
+#if defined __MSVCRT__ || defined __OS2__ || defined __DJGPP__
setmode( STDIN_FILENO, O_BINARY );
setmode( STDOUT_FILENO, O_BINARY );
#endif
diff --git a/testsuite/check.sh b/testsuite/check.sh
index c1f86e6..33ffb8a 100755
--- a/testsuite/check.sh
+++ b/testsuite/check.sh
@@ -1,6 +1,6 @@
#! /bin/sh
# check script for Lzd - Educational decompressor for the lzip format
-# Copyright (C) 2013-2021 Antonio Diaz Diaz.
+# Copyright (C) 2013-2022 Antonio Diaz Diaz.
#
# This script is free software: you have unlimited permission
# to copy, distribute, and modify it.
@@ -46,11 +46,11 @@ for i in "${in_lz}" "${in_em}" ; do
done
cat "${in}" "${in}" > in2 || framework_failure
-cat "${in_lz}" "${in_lz}" > in2.lz || framework_failure
-"${LZIP}" < in2.lz > copy2 || test_failed $LINENO
+cat "${in_lz}" "${in_lz}" | "${LZIP}" > copy2 || test_failed $LINENO
cmp in2 copy2 || test_failed $LINENO
+rm -f copy2 || framework_failure
-cat in2.lz > copy2.lz || framework_failure
+cat "${in_lz}" "${in_lz}" > copy2.lz || framework_failure
printf "\ngarbage" >> copy2.lz || framework_failure
"${LZIP}" -d < copy2.lz > copy2 || test_failed $LINENO
cmp in2 copy2 || test_failed $LINENO
@@ -72,24 +72,25 @@ for i in fox_bcrc.lz fox_crc0.lz fox_das46.lz fox_mes81.lz ; do
done
rm -f fox out || framework_failure
+cat "${in_lz}" "${in_lz}" > in2.lz || framework_failure
cat "${in_lz}" "${in_lz}" "${in_lz}" > in3.lz || framework_failure
if dd if=in3.lz of=trunc.lz bs=14752 count=1 2> /dev/null &&
[ -e trunc.lz ] && cmp in2.lz trunc.lz > /dev/null 2>&1 ; then
# can't detect truncated header of non-first member
for i in 6 20 14734 14758 ; do
dd if=in3.lz of=trunc.lz bs=$i count=1 2> /dev/null
- "${LZIP}" < trunc.lz > out 2> /dev/null
+ "${LZIP}" < trunc.lz > /dev/null 2>&1
[ $? = 2 ] || test_failed $LINENO $i
done
else
printf "\nwarning: skipping truncation test: 'dd' does not work on your system."
fi
-rm -f in2.lz in3.lz trunc.lz out || framework_failure
+rm -f in2.lz in3.lz trunc.lz || framework_failure
cat "${in_lz}" > ingin.lz || framework_failure
printf "g" >> ingin.lz || framework_failure
cat "${in_lz}" >> ingin.lz || framework_failure
-"${LZIP}" < ingin.lz > copy || test_failed $LINENO
+"${LZIP}" -d < ingin.lz > copy || test_failed $LINENO
cmp "${in}" copy || test_failed $LINENO
rm -f copy ingin.lz || framework_failure