summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AUTHORS7
-rw-r--r--COPYING26
-rw-r--r--ChangeLog33
-rw-r--r--INSTALL26
-rw-r--r--Makefile.in18
-rw-r--r--NEWS10
-rw-r--r--README71
-rwxr-xr-xconfigure44
-rw-r--r--debian/changelog109
-rw-r--r--debian/control9
-rw-r--r--debian/copyright6
-rw-r--r--debian/lzd.manpages1
-rwxr-xr-xdebian/lzd.postinst35
-rwxr-xr-xdebian/lzd.prerm29
-rw-r--r--debian/manpages/lzd.117
-rw-r--r--debian/patches/debian/0001-build.patch8
-rwxr-xr-xdebian/rules17
-rw-r--r--debian/watch2
-rw-r--r--lzd.cc171
-rwxr-xr-xtestsuite/check.sh49
-rw-r--r--testsuite/fox.lzbin0 -> 80 bytes
-rw-r--r--testsuite/fox_bcrc.lzbin0 -> 80 bytes
-rw-r--r--testsuite/fox_bm.lzbin0 -> 80 bytes
-rw-r--r--testsuite/fox_crc0.lzbin0 -> 80 bytes
-rw-r--r--testsuite/fox_das46.lzbin0 -> 80 bytes
-rw-r--r--testsuite/fox_de20.lzbin0 -> 80 bytes
-rw-r--r--testsuite/fox_mes81.lzbin0 -> 80 bytes
-rw-r--r--testsuite/fox_s11.lzbin0 -> 80 bytes
-rw-r--r--testsuite/fox_v2.lzbin0 -> 80 bytes
-rw-r--r--testsuite/test_em.txt.lzbin0 -> 14024 bytes
30 files changed, 401 insertions, 287 deletions
diff --git a/AUTHORS b/AUTHORS
index a7b5945..48f7099 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,7 +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 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).
+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/COPYING b/COPYING
index 5b9d8b9..0105f19 100644
--- a/COPYING
+++ b/COPYING
@@ -1,17 +1,17 @@
- Lzd - Educational decompressor for the lzip format
- Copyright (C) Antonio Diaz Diaz.
+ Lzd - Educational decompressor for the lzip format
+ Copyright (C) Antonio Diaz Diaz.
- This program is free software. Redistribution and use in source and
- binary forms, with or without modification, are permitted provided
- that the following conditions are met:
+ This program is free software. Redistribution and use in source and
+ binary forms, with or without modification, are permitted provided
+ that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions, and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions, and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/ChangeLog b/ChangeLog
index eae5639..f417214 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,28 @@
+2024-01-02 Antonio Diaz Diaz <antonio@gnu.org>
+
+ * Version 1.4 released.
+ * lzd.cc: Use header_size and trailer_size instead of 6 and 20.
+
+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.
+ * lzd.cc (main): Check also mismatches in member size.
+ Accept and ignore the option '-d' for compatibility with zutils.
+ Remove warning about "lzd not safe for real work".
+ Print license notice.
+ * testsuite: Add 10 new test files.
+
2019-01-11 Antonio Diaz Diaz <antonio@gnu.org>
* Version 1.1 released.
- * File_* renamed to Lzip_*.
+ * 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>
@@ -19,7 +38,7 @@
2016-01-23 Antonio Diaz Diaz <antonio@gnu.org>
* Version 0.8 released.
- * Documented that lzip does not use 'literal_pos_state_bits'.
+ * Document that lzip does not use 'literal_pos_state_bits'.
2015-07-07 Antonio Diaz Diaz <antonio@gnu.org>
@@ -39,7 +58,7 @@
2013-08-01 Antonio Diaz Diaz <antonio@gnu.org>
* Version 0.4 released.
- * check.sh: Removed '/dev/full' from tests.
+ * check.sh: Remove '/dev/full' from tests.
2013-07-24 Antonio Diaz Diaz <antonio@gnu.org>
@@ -49,15 +68,15 @@
2013-05-06 Antonio Diaz Diaz <antonio@gnu.org>
* Version 0.2 released.
- * main.c: Added a missing '#include' for OS/2.
+ * main.c: Add a missing '#include' for OS/2.
2013-03-21 Antonio Diaz Diaz <ant_diaz@teleline.es>
* Version 0.1 released.
-Copyright (C) 2013-2019 Antonio Diaz Diaz.
+Copyright (C) 2013-2024 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
+but just in case, you have unlimited permission to copy, distribute, and
modify it.
diff --git a/INSTALL b/INSTALL
index 55b2603..2c82368 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,7 +1,8 @@
Requirements
------------
-You will need a C++ compiler.
-I use gcc 5.3.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).
@@ -30,27 +31,28 @@ the main archive.
4. Optionally, type 'make check' to run the tests that come with lzd.
5. Type 'make install' to install the program and any data files and
- documentation.
+ documentation. You need root privileges to install into a prefix owned
+ by root.
Another way
-----------
You can also compile lzd into a separate directory.
-To do this, you must use a version of 'make' that supports the 'VPATH'
-variable, such as GNU 'make'. 'cd' to the directory where you want the
+To do this, you must use a version of 'make' that supports the variable
+'VPATH', such as GNU 'make'. 'cd' to the directory where you want the
object files and executables to go and run the 'configure' script.
-'configure' automatically checks for the source code in '.', in '..' and
+'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-2019 Antonio Diaz Diaz.
+Copyright (C) 2013-2024 Antonio Diaz Diaz.
This file is free documentation: you have unlimited permission to copy,
-distribute and modify it.
+distribute, and modify it.
diff --git a/Makefile.in b/Makefile.in
index 471ff4b..120a41b 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -19,20 +19,23 @@ 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 $@ $<
-$(objs) : Makefile
+# prevent 'make' from trying to remake source files
+$(VPATH)/configure $(VPATH)/Makefile.in $(VPATH)/doc/$(pkgname).texi : ;
+%.h %.cc : ;
+$(objs) : Makefile
doc :
info : $(VPATH)/doc/$(pkgname).info
$(VPATH)/doc/$(pkgname).info : $(VPATH)/doc/$(pkgname).texi
- cd $(VPATH)/doc && makeinfo $(pkgname).texi
+ cd $(VPATH)/doc && $(MAKEINFO) $(pkgname).texi
man : $(VPATH)/doc/$(progname).1
@@ -63,7 +66,7 @@ install-info :
-rm -f "$(DESTDIR)$(infodir)/$(pkgname).info"*
$(INSTALL_DATA) $(VPATH)/doc/$(pkgname).info "$(DESTDIR)$(infodir)/$(pkgname).info"
-if $(CAN_RUN_INSTALLINFO) ; then \
- install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$(pkgname).info" ; \
+ install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$(pkgname).info" ; \
fi
install-info-compress : install-info
@@ -84,7 +87,7 @@ uninstall-bin :
uninstall-info :
-if $(CAN_RUN_INSTALLINFO) ; then \
- install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$(pkgname).info" ; \
+ install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$(pkgname).info" ; \
fi
-rm -f "$(DESTDIR)$(infodir)/$(pkgname).info"*
@@ -105,7 +108,10 @@ dist : doc
$(DISTNAME)/*.cc \
$(DISTNAME)/testsuite/check.sh \
$(DISTNAME)/testsuite/test.txt \
- $(DISTNAME)/testsuite/test.txt.lz
+ $(DISTNAME)/testsuite/fox.lz \
+ $(DISTNAME)/testsuite/fox_*.lz \
+ $(DISTNAME)/testsuite/test.txt.lz \
+ $(DISTNAME)/testsuite/test_em.txt.lz
rm -f $(DISTNAME)
lzip -v -9 $(DISTNAME).tar
diff --git a/NEWS b/NEWS
index b22edc2..be2c30b 100644
--- a/NEWS
+++ b/NEWS
@@ -1,8 +1,4 @@
-Changes in version 1.1:
+Changes in version 1.4:
-All 'File_*' identifiers have been renamed to 'Lzip_*'.
-
-Lzd now should compile on DOS with DJGPP.
-
-The configure script now accepts appending options to CXXFLAGS using the
-syntax 'CXXFLAGS+=OPTIONS'.
+Define constants 'header_size' and 'trailer_size' instead of using 6 and 20.
+(Lzd is supposed to be educational, and using numbers is bad practice).
diff --git a/README b/README
index 4b639c6..03fb742 100644
--- a/README
+++ b/README
@@ -1,54 +1,37 @@
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. It is not safe to use lzd for any real work.
-
-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 decompresses from standard input to standard output. Lzd will
-correctly decompress the concatenation of two or more compressed files.
-The result is the concatenation of the corresponding decompressed data.
-Integrity of such concatenated compressed input is also verified.
-
-The lzip file format is designed for data sharing and long-term 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 source 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 the lzip reference implementation 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.
+purpose. Studying its source code is a good first step to understand how
+lzip works. Lzd is written in C++.
+
+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 checks the 3 integrity factors.
+
+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
+
+Lzd decompresses from standard input to standard output. It accepts (and
+ignores) the option '-d' for compatibility with other lzip tools. In
+particular, accepting the option '-d' allows lzd to be used as argument to
+the option '--lz' of the tools from the zutils package.
+
+Lzd correctly decompresses the concatenation of two or more compressed
+files. The result is the concatenation of the corresponding decompressed
+data. Integrity of such concatenated compressed input is also checked.
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 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).
+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-2019 Antonio Diaz Diaz.
+Copyright (C) 2013-2024 Antonio Diaz Diaz.
This file is free documentation: you have unlimited permission to copy,
-distribute and modify it.
+distribute, and modify it.
-The file Makefile.in is a data file used by configure to produce the
-Makefile. It has the same copyright owner and permissions that configure
-itself.
+The file Makefile.in is a data file used by configure to produce the Makefile.
+It has the same copyright owner and permissions that configure itself.
diff --git a/configure b/configure
index a4e000e..a84fda2 100755
--- a/configure
+++ b/configure
@@ -1,12 +1,12 @@
#! /bin/sh
# configure script for Lzd - Educational decompressor for the lzip format
-# Copyright (C) 2013-2019 Antonio Diaz Diaz.
+# Copyright (C) 2013-2024 Antonio Diaz Diaz.
#
# This configure script is free software: you have unlimited permission
-# to copy, distribute and modify it.
+# to copy, distribute, and modify it.
pkgname=lzd
-pkgversion=1.1
+pkgversion=1.4
progname=lzd
srctrigger=lzd.cc
@@ -24,13 +24,10 @@ CXX=g++
CPPFLAGS=
CXXFLAGS='-Wall -W -O2'
LDFLAGS=
+MAKEINFO=makeinfo
# checking whether we are using GNU C++.
-/bin/sh -c "${CXX} --version" > /dev/null 2>&1 ||
- {
- CXX=c++
- CXXFLAGS=-O2
- }
+/bin/sh -c "${CXX} --version" > /dev/null 2>&1 || { CXX=c++ ; CXXFLAGS=-O2 ; }
# Loop over all args
args=
@@ -42,11 +39,12 @@ while [ $# != 0 ] ; do
shift
# Add the argument quoted to args
- args="${args} \"${option}\""
+ if [ -z "${args}" ] ; then args="\"${option}\""
+ else args="${args} \"${option}\"" ; fi
# Split out the argument for options that take them
case ${option} in
- *=*) optarg=`echo ${option} | sed -e 's,^[^=]*=,,;s,/$,,'` ;;
+ *=*) optarg=`echo "${option}" | sed -e 's,^[^=]*=,,;s,/$,,'` ;;
esac
# Process the options
@@ -60,7 +58,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}]"
@@ -68,10 +66,11 @@ while [ $# != 0 ] ; do
echo " --infodir=DIR info files directory [${infodir}]"
echo " --mandir=DIR man pages directory [${mandir}]"
echo " CXX=COMPILER C++ compiler to use [${CXX}]"
- echo " CPPFLAGS=OPTIONS command line options for the preprocessor [${CPPFLAGS}]"
- echo " CXXFLAGS=OPTIONS command line options for the C++ compiler [${CXXFLAGS}]"
+ echo " CPPFLAGS=OPTIONS command-line options for the preprocessor [${CPPFLAGS}]"
+ echo " CXXFLAGS=OPTIONS command-line options for the C++ compiler [${CXXFLAGS}]"
echo " CXXFLAGS+=OPTIONS append options to the current value of CXXFLAGS"
- echo " LDFLAGS=OPTIONS command line options for the linker [${LDFLAGS}]"
+ echo " LDFLAGS=OPTIONS command-line options for the linker [${LDFLAGS}]"
+ echo " MAKEINFO=NAME makeinfo program to use [${MAKEINFO}]"
echo
exit 0 ;;
--version | -V)
@@ -99,6 +98,7 @@ while [ $# != 0 ] ; do
CXXFLAGS=*) CXXFLAGS=${optarg} ;;
CXXFLAGS+=*) CXXFLAGS="${CXXFLAGS} ${optarg}" ;;
LDFLAGS=*) LDFLAGS=${optarg} ;;
+ MAKEINFO=*) MAKEINFO=${optarg} ;;
--*)
echo "configure: WARNING: unrecognized option: '${option}'" 1>&2 ;;
@@ -118,19 +118,19 @@ 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=.
if [ ! -r "${srcdir}/${srctrigger}" ] ; then srcdir=.. ; fi
if [ ! -r "${srcdir}/${srctrigger}" ] ; then
## the sed command below emulates the dirname command
- srcdir=`echo $0 | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+ srcdir=`echo "$0" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
fi
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
@@ -148,9 +148,9 @@ if [ -z "${no_create}" ] ; then
# Run this file to recreate the current configuration.
#
# This script is free software: you have unlimited permission
-# to copy, distribute and modify it.
+# to copy, distribute, and modify it.
-exec /bin/sh $0 ${args} --no-create
+exec /bin/sh "$0" ${args} --no-create
EOF
chmod +x config.status
fi
@@ -167,14 +167,15 @@ echo "CXX = ${CXX}"
echo "CPPFLAGS = ${CPPFLAGS}"
echo "CXXFLAGS = ${CXXFLAGS}"
echo "LDFLAGS = ${LDFLAGS}"
+echo "MAKEINFO = ${MAKEINFO}"
rm -f Makefile
cat > Makefile << EOF
# Makefile for Lzd - Educational decompressor for the lzip format
-# Copyright (C) 2013-2019 Antonio Diaz Diaz.
+# Copyright (C) 2013-2024 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.
+# to copy, distribute, and modify it.
pkgname = ${pkgname}
pkgversion = ${pkgversion}
@@ -190,6 +191,7 @@ CXX = ${CXX}
CPPFLAGS = ${CPPFLAGS}
CXXFLAGS = ${CXXFLAGS}
LDFLAGS = ${LDFLAGS}
+MAKEINFO = ${MAKEINFO}
EOF
cat "${srcdir}/Makefile.in" >> Makefile
diff --git a/debian/changelog b/debian/changelog
index f475d5b..79c4926 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,112 @@
+lzd (1.4-1) sid; urgency=medium
+
+ * Uploading to sid.
+ * Merging upstream version 1.4.
+ * Refreshing build.patch.
+ * Disabling testsuite for now as the current upstream release misses
+ some files for it to run at all.
+
+ -- Daniel Baumann <daniel.baumann@progress-linux.org> Tue, 23 Jan 2024 06:17:15 +0100
+
+lzd (1.3-2) sid; urgency=medium
+
+ * Uploading to sid.
+ * Updating to standards version 4.6.2.
+
+ -- Daniel Baumann <daniel.baumann@progress-linux.org> Mon, 30 Jan 2023 17:37:57 +0100
+
+lzd (1.3-1) sid; urgency=medium
+
+ * Uploading to sid.
+ * Merging upstream version 1.3.
+ * Updating http links to https in copyright.
+ * Updating year in upstream copyright for 2022.
+
+ -- Daniel Baumann <daniel.baumann@progress-linux.org> Sat, 05 Nov 2022 19:38:20 +0100
+
+lzd (1.2-7) sid; urgency=medium
+
+ * Uploading to sid.
+ * Correcting version mangling in watch file.
+
+ -- Daniel Baumann <daniel.baumann@progress-linux.org> Thu, 14 Jul 2022 19:39:00 +0200
+
+lzd (1.2-6) sid; urgency=medium
+
+ * Uploading to sid.
+ * Updating to standards version 4.6.1.
+ * Adding manpage for lzd, thanks to Sakirnth Nagarasa
+ <sakirnth@gmail.com> (Closes: #1013327).
+
+ -- Daniel Baumann <daniel.baumann@progress-linux.org> Thu, 14 Jul 2022 14:42:47 +0200
+
+lzd (1.2-5) sid; urgency=medium
+
+ * Uploading to sid.
+ * Correcting typo in watch file.
+
+ -- Daniel Baumann <daniel.baumann@progress-linux.org> Tue, 05 Apr 2022 04:01:21 +0200
+
+lzd (1.2-4) sid; urgency=medium
+
+ * Uploading to sid.
+ * Updating packaging copyright for 2022.
+ * Handling pre/rc versions in watch file.
+
+ -- Daniel Baumann <daniel.baumann@progress-linux.org> Fri, 11 Mar 2022 07:09:04 +0100
+
+lzd (1.2-3) sid; urgency=medium
+
+ * Uploading to sid.
+ * Removing lzd from lzip alternatives as it doesn't provide the '--test'
+ parameter to verify compressed file integrity (which now is the base-
+ line requirement for all lzip variants providing alternatives).
+
+ -- Daniel Baumann <daniel.baumann@progress-linux.org> Wed, 29 Dec 2021 03:34:31 +0100
+
+lzd (1.2-2) sid; urgency=medium
+
+ * Uploading to sid.
+ * Updating watch file.
+ * Updating to standards version 4.6.0.
+
+ -- Daniel Baumann <daniel.baumann@progress-linux.org> Sat, 09 Oct 2021 09:44:40 +0200
+
+lzd (1.2-1) sid; urgency=medium
+
+ * Uploading to sid.
+ * Merging upstream version 1.2.
+ * Refreshing build.patch.
+ * Updating to standards version 4.5.1.
+ * Updating years in copyright file for 2021.
+
+ -- Daniel Baumann <daniel.baumann@progress-linux.org> Mon, 25 Jan 2021 14:41:39 +0100
+
+lzd (1.1-8) sid; urgency=medium
+
+ * Uploading to sid.
+ * Dropping using help2man.
+ * Adding patch from Helmut Grohne <helmut@subdivi.de> to improve cross
+ building by using the host compiler (Closes: #959521).
+
+ -- Daniel Baumann <daniel.baumann@progress-linux.org> Sun, 14 Jun 2020 11:22:25 +0200
+
+lzd (1.1-7) sid; urgency=medium
+
+ * Uploading to sid.
+ * Using execute_after targets in rules to be explicit what we're doing.
+ * Updating to debhelper version 13.
+
+ -- Daniel Baumann <daniel.baumann@progress-linux.org> Sun, 19 Apr 2020 13:51:30 +0200
+
+lzd (1.1-6) sid; urgency=medium
+
+ * Uploading to sid.
+ * Updating years in copyright file for 2020.
+ * Updating to standards version 4.5.0.
+
+ -- Daniel Baumann <daniel.baumann@progress-linux.org> Sat, 25 Jan 2020 19:30:12 +0100
+
lzd (1.1-5) sid; urgency=medium
* Uploading to sid.
diff --git a/debian/control b/debian/control
index d26418f..22a9f66 100644
--- a/debian/control
+++ b/debian/control
@@ -3,10 +3,9 @@ Section: utils
Priority: optional
Maintainer: Daniel Baumann <daniel.baumann@progress-linux.org>
Build-Depends:
- debhelper-compat (= 12),
- help2man,
+ debhelper-compat (= 13),
Rules-Requires-Root: no
-Standards-Version: 4.4.1
+Standards-Version: 4.7.0
Homepage: http://www.nongnu.org/lzip/lzd.html
Vcs-Browser: https://git.progress-linux.org/users/daniel.baumann/debian/packages/lzd
Vcs-Git: https://git.progress-linux.org/users/daniel.baumann/debian/packages/lzd
@@ -17,10 +16,6 @@ Architecture: any
Depends:
${misc:Depends},
${shlibs:Depends},
-Provides:
- lzip-alternative,
- lzip-compressor,
- lzip-decompressor,
Description: Educational, lossless data compressor based on the LZMA algorithm
Lzip is a lossless data compressor based on the LZMA algorithm, with very safe
integrity checking and a user interface similar to the one of gzip or bzip2.
diff --git a/debian/copyright b/debian/copyright
index fed08e3..0f3d3cf 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -1,14 +1,14 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Lzd
Upstream-Contact: lzip-bug@nongnu.org
-Source: http://download.savannah.gnu.org/releases/lzip/
+Source: https://download.savannah.gnu.org/releases/lzip/
Files: *
-Copyright: 2013-2019 Antonio Diaz Diaz <ant_diaz@teleline.es>
+Copyright: 2013-2024 Antonio Diaz Diaz <ant_diaz@teleline.es>
License: PD
Files: debian/*
-Copyright: 2013-2020 Daniel Baumann <daniel.baumann@progress-linux.org>
+Copyright: 2013-2024 Daniel Baumann <daniel.baumann@progress-linux.org>
License: PD
License: PD
diff --git a/debian/lzd.manpages b/debian/lzd.manpages
new file mode 100644
index 0000000..2fb19fb
--- /dev/null
+++ b/debian/lzd.manpages
@@ -0,0 +1 @@
+debian/manpages/*
diff --git a/debian/lzd.postinst b/debian/lzd.postinst
deleted file mode 100755
index 508a294..0000000
--- a/debian/lzd.postinst
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/sh
-
-set -e
-
-case "${1}" in
- configure)
- # lzip-alternative
- update-alternatives --quiet \
- --install /usr/bin/lzip lzip /usr/bin/lzip.lzd -2000 \
- --slave /usr/share/man/man1/lzip.1.gz lzip.1.gz /usr/share/man/man1/lzip.lzd.1.gz
-
- # lzip-compressor
- update-alternatives --quiet \
- --install /usr/bin/lzip-compressor lzip-compressor /usr/bin/lzip.lzd -2000 \
- --slave /usr/share/man/man1/lzip-compressor.1.gz lzip-compressor.1.gz /usr/share/man/man1/lzip.lzd.1.gz
-
- # lzip-decompressor
- update-alternatives --quiet \
- --install /usr/bin/lzip-decompressor lzip-decompressor /usr/bin/lzip.lzd -2000 \
- --slave /usr/share/man/man1/lzip-decompressor.1.gz lzip-decompressor.1.gz /usr/share/man/man1/lzip.lzd.1.gz
- ;;
-
- abort-upgrade|abort-remove|abort-deconfigure)
-
- ;;
-
- *)
- echo "postinst called with unknown argument \`${1}'" >&2
- exit 1
- ;;
-esac
-
-#DEBHELPER#
-
-exit 0
diff --git a/debian/lzd.prerm b/debian/lzd.prerm
deleted file mode 100755
index 3ad403d..0000000
--- a/debian/lzd.prerm
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/sh
-
-set -e
-
-case "${1}" in
- remove|upgrade|deconfigure)
- # lzip-alternative
- update-alternatives --quiet --remove lzip /usr/bin/lzip.lzd
-
- # lzip-compressor
- update-alternatives --quiet --remove lzip-compressor /usr/bin/lzip.lzd
-
- # lzip-decompressor
- update-alternatives --quiet --remove lzip-decompressor /usr/bin/lzip.lzd
- ;;
-
- failed-upgrade)
-
- ;;
-
- *)
- echo "prerm called with unknown argument \`${1}'" >&2
- exit 1
- ;;
-esac
-
-#DEBHELPER#
-
-exit 0
diff --git a/debian/manpages/lzd.1 b/debian/manpages/lzd.1
new file mode 100644
index 0000000..b65f5df
--- /dev/null
+++ b/debian/manpages/lzd.1
@@ -0,0 +1,17 @@
+.TH LZD "1" "2022-06-21" "lzd" "User Commands"
+.SH NAME
+lzd \- simplified lzip format decompressor
+.SH SYNOPSIS
+.B lzd
+[ -d ] < file.lz > file
+.SH DESCRIPTION
+This manual describes the usage of lzd. It is a simplified lzip decompressor for educational purpose. lzd is compliant with the lzip specification. Therefore it can verify the 3 integrity factors.
+.PP
+The command can take a lzip compressed file in stdin and it will decompress it to stdout.
+.SH OPTIONS
+.TP
+\fB\-d\fR
+Only for compatibility for other lzip tools.
+.PP
+.SH SEE ALSO
+lzip(1)
diff --git a/debian/patches/debian/0001-build.patch b/debian/patches/debian/0001-build.patch
index fa83fa9..7d55240 100644
--- a/debian/patches/debian/0001-build.patch
+++ b/debian/patches/debian/0001-build.patch
@@ -4,16 +4,18 @@ Description: Avoid overwriting build-environment.
diff -Naurp lzd.orig/configure lzd/configure
--- lzd.orig/configure
+++ lzd/configure
-@@ -21,9 +21,9 @@ datarootdir='$(prefix)/share'
+@@ -20,10 +20,10 @@ bindir='$(exec_prefix)/bin'
+ datarootdir='$(prefix)/share'
infodir='$(datarootdir)/info'
mandir='$(datarootdir)/man'
- CXX=g++
+-CXX=g++
-CPPFLAGS=
-CXXFLAGS='-Wall -W -O2'
-LDFLAGS=
++#CXX=g++
+#CPPFLAGS=
+#CXXFLAGS='-Wall -W -O2'
+#LDFLAGS=
+ MAKEINFO=makeinfo
# checking whether we are using GNU C++.
- /bin/sh -c "${CXX} --version" > /dev/null 2>&1 ||
diff --git a/debian/rules b/debian/rules
index ddb0752..14ddc7d 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,18 +1,15 @@
#!/usr/bin/make -f
+-include /usr/share/dpkg/buildtools.mk
+
%:
dh ${@}
+override_dh_auto_configure:
+ dh_auto_configure -- 'CXX=$(CXX)'
+
override_dh_auto_install:
dh_auto_install -- DESTDIR=$(CURDIR)/debian/lzd
- # man
- mkdir -p debian/lzd/usr/share/man/man1
- help2man --name 'Educational decompressor for the lzip format.' debian/lzd/usr/bin/lzd > debian/lzd/usr/share/man/man1/lzd.1
-
- # update-alternatives
- mv debian/lzd/usr/bin/lzd debian/lzd/usr/bin/lzip.lzd
- ln -s /usr/bin/lzip.lzd debian/lzd/usr/bin/lzd
-
- mv debian/lzd/usr/share/man/man1/lzd.1 debian/lzd/usr/share/man/man1/lzip.lzd.1
- ln -s /usr/share/man/man1/lzip.lzd.1.gz debian/lzd/usr/share/man/man1/lzd.1.gz
+override_dh_auto_test:
+ # disabled: incomplete upstream testsuite
diff --git a/debian/watch b/debian/watch
index 0137853..cce2c21 100644
--- a/debian/watch
+++ b/debian/watch
@@ -1,3 +1,3 @@
version=4
opts="pgpmode=auto, uversionmangle=s/(\d)\-?((pre|rc)\d*)$/$1~$2/" \
-https://download.savannah.gnu.org/releases/lzip/lzd/lzd-(.+)\.tar\.lz
+https://download.savannah.gnu.org/releases/lzip/lzd/@PACKAGE@@ANY_VERSION@\.tar\.lz
diff --git a/lzd.cc b/lzd.cc
index 503bc36..3cf3f13 100644
--- a/lzd.cc
+++ b/lzd.cc
@@ -1,25 +1,25 @@
-/* Lzd - Educational decompressor for the lzip format
- Copyright (C) 2013-2019 Antonio Diaz Diaz.
+/* Lzd - Educational decompressor for the lzip format
+ Copyright (C) 2013-2024 Antonio Diaz Diaz.
- This program is free software. Redistribution and use in source and
- binary forms, with or without modification, are permitted provided
- that the following conditions are met:
+ This program is free software. Redistribution and use in source and
+ binary forms, with or without modification, are permitted provided
+ that the following conditions are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions, and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions, and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/*
- 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.
+ Exit status: 0 for a normal exit, 1 for environmental problems
+ (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
@@ -47,7 +47,7 @@ public:
void set_char()
{
- static const int next[states] = { 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 };
+ const int next[states] = { 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 };
st = next[st];
}
void set_match() { st = ( st < 7 ) ? 7 : 10; }
@@ -69,7 +69,7 @@ enum {
dis_slot_bits = 6,
start_dis_model = 4,
end_dis_model = 14,
- modeled_distances = 1 << (end_dis_model / 2), // 128
+ modeled_distances = 1 << ( end_dis_model / 2 ), // 128
dis_align_bits = 4,
dis_align_size = 1 << dis_align_bits,
@@ -130,25 +130,31 @@ public:
const CRC32 crc32;
-typedef uint8_t Lzip_header[6]; // 0-3 magic, 4 version, 5 coded_dict_size
-
-typedef uint8_t Lzip_trailer[20];
+enum { header_size = 6, trailer_size = 20 };
+typedef uint8_t Lzip_header[header_size]; // 0-3 magic bytes
+ // 4 version
+ // 5 coded dictionary size
+typedef uint8_t Lzip_trailer[trailer_size];
// 0-3 CRC32 of the uncompressed data
// 4-11 size of the uncompressed data
// 12-19 member size including header and trailer
class Range_decoder
{
+ unsigned long long member_pos;
uint32_t code;
uint32_t range;
public:
- Range_decoder() : code( 0 ), range( 0xFFFFFFFFU )
+ Range_decoder()
+ : member_pos( header_size ), 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() { return std::getc( stdin ); }
+ uint8_t get_byte() { ++member_pos; return std::getc( stdin ); }
+ unsigned long long member_position() const { return member_pos; }
unsigned decode( const int num_bits )
{
@@ -159,30 +165,31 @@ public:
symbol <<= 1;
if( code >= range ) { code -= range; symbol |= 1; }
if( range <= 0x00FFFFFFU ) // normalize
- { range <<= 8; code = (code << 8) | get_byte(); }
+ { range <<= 8; code = ( code << 8 ) | get_byte(); }
}
return symbol;
}
- unsigned decode_bit( Bit_model & bm )
+ bool decode_bit( Bit_model & bm )
{
- unsigned symbol;
+ bool symbol;
const uint32_t bound = ( range >> bit_model_total_bits ) * bm.probability;
if( code < bound )
{
range = bound;
- bm.probability += (bit_model_total - bm.probability) >> bit_model_move_bits;
+ bm.probability +=
+ ( bit_model_total - bm.probability ) >> bit_model_move_bits;
symbol = 0;
}
else
{
- range -= bound;
code -= bound;
+ range -= bound;
bm.probability -= bm.probability >> bit_model_move_bits;
symbol = 1;
}
if( range <= 0x00FFFFFFU ) // normalize
- { range <<= 8; code = (code << 8) | get_byte(); }
+ { range <<= 8; code = ( code << 8 ) | get_byte(); }
return symbol;
}
@@ -191,7 +198,7 @@ public:
unsigned symbol = 1;
for( int i = 0; i < num_bits; ++i )
symbol = ( symbol << 1 ) | decode_bit( bm[symbol] );
- return symbol - (1 << num_bits);
+ return symbol - ( 1 << num_bits );
}
unsigned decode_tree_reversed( Bit_model bm[], const int num_bits )
@@ -211,8 +218,8 @@ public:
unsigned symbol = 1;
for( int i = 7; i >= 0; --i )
{
- const unsigned match_bit = ( match_byte >> i ) & 1;
- const unsigned bit = decode_bit( bm[symbol+(match_bit<<8)+0x100] );
+ const bool match_bit = ( match_byte >> i ) & 1;
+ const bool bit = decode_bit( bm[symbol+(match_bit<<8)+0x100] );
symbol = ( symbol << 1 ) | bit;
if( match_bit != bit )
{
@@ -227,11 +234,12 @@ public:
unsigned decode_len( Len_model & lm, const int pos_state )
{
if( decode_bit( lm.choice1 ) == 0 )
- return decode_tree( lm.bm_low[pos_state], len_low_bits );
+ return min_match_len +
+ decode_tree( lm.bm_low[pos_state], len_low_bits );
if( decode_bit( lm.choice2 ) == 0 )
- return len_low_symbols +
+ return min_match_len + len_low_symbols +
decode_tree( lm.bm_mid[pos_state], len_mid_bits );
- return len_low_symbols + len_mid_symbols +
+ return min_match_len + len_low_symbols + len_mid_symbols +
decode_tree( lm.bm_high, len_high_bits );
}
};
@@ -278,7 +286,11 @@ public:
~LZ_decoder() { delete[] buffer; }
unsigned crc() const { return crc_ ^ 0xFFFFFFFFU; }
- unsigned long long data_position() const { return partial_data_pos + pos; }
+ unsigned long long data_position() const
+ { return partial_data_pos + pos; }
+ uint8_t get_byte() { return rdec.get_byte(); }
+ unsigned long long member_position() const
+ { return rdec.member_position(); }
bool decode_member();
};
@@ -290,7 +302,6 @@ void LZ_decoder::flush_data()
{
const unsigned size = pos - stream_pos;
crc32.update_buf( crc_, buffer + stream_pos, size );
- errno = 0;
if( std::fwrite( buffer + stream_pos, 1, size, stdout ) != size )
{ std::fprintf( stderr, "Write error: %s\n", std::strerror( errno ) );
std::exit( 1 ); }
@@ -301,7 +312,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];
@@ -363,12 +374,12 @@ bool LZ_decoder::decode_member() // Returns false if error
rep0 = distance;
}
state.set_rep();
- len = min_match_len + rdec.decode_len( rep_len_model, pos_state );
+ len = rdec.decode_len( rep_len_model, pos_state );
}
else // match
{
rep3 = rep2; rep2 = rep1; rep1 = rep0;
- len = min_match_len + rdec.decode_len( match_len_model, pos_state );
+ len = rdec.decode_len( match_len_model, pos_state );
const int len_state = std::min( len - min_match_len, len_states - 1 );
rep0 = rdec.decode_tree( bm_dis_slot[len_state], dis_slot_bits );
if( rep0 >= start_dis_model )
@@ -381,12 +392,13 @@ bool LZ_decoder::decode_member() // Returns false if error
direct_bits );
else
{
- rep0 += rdec.decode( direct_bits - dis_align_bits ) << dis_align_bits;
+ rep0 +=
+ rdec.decode( direct_bits - dis_align_bits ) << dis_align_bits;
rep0 += rdec.decode_tree_reversed( bm_align, dis_align_bits );
if( rep0 == 0xFFFFFFFFU ) // marker found
{
flush_data();
- return ( len == min_match_len ); // End Of Stream marker
+ return len == min_match_len; // End Of Stream marker
}
}
}
@@ -403,61 +415,74 @@ bool LZ_decoder::decode_member() // Returns false if error
int main( const int argc, const char * const argv[] )
{
- if( argc > 1 )
+ if( argc > 2 || ( argc == 2 && std::strcmp( argv[1], "-d" ) != 0 ) )
{
- std::printf( "Lzd %s - Educational decompressor for the lzip format.\n",
- PROGVERSION );
- std::printf( "Study the source to learn how a lzip decompressor works.\n"
- "See the lzip manual for an explanation of the code.\n"
- "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) 2019 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"
- "Lzd home page: http://www.nongnu.org/lzip/lzd.html\n" );
+ std::printf(
+ "Lzd %s - Educational decompressor for the lzip format.\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) 2024 Antonio Diaz Diaz.\n"
+ "License 2-clause BSD.\n"
+ "This is free software: you are free to change and redistribute "
+ "it.\nThere is NO WARRANTY, to the extent permitted by law.\n"
+ "Report bugs to lzip-bug@nongnu.org\n"
+ "Lzd home page: http://www.nongnu.org/lzip/lzd.html\n",
+ PROGVERSION, argv[0] );
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
for( bool first_member = true; ; first_member = false )
{
- Lzip_header header; // verify header
- for( int i = 0; i < 6; ++i ) header[i] = std::getc( stdin );
+ Lzip_header header; // check header
+ for( int i = 0; i < header_size; ++i ) header[i] = std::getc( stdin );
if( std::feof( stdin ) || std::memcmp( header, "LZIP\x01", 5 ) != 0 )
{
if( first_member )
- { std::fputs( "Bad magic number (file not in lzip format).\n", stderr );
- return 2; }
- break;
+ { std::fputs( "Bad magic number (file not in lzip format).\n",
+ stderr ); return 2; }
+ break; // ignore trailing data
}
unsigned dict_size = 1 << ( header[5] & 0x1F );
dict_size -= ( dict_size / 16 ) * ( ( header[5] >> 5 ) & 7 );
if( dict_size < min_dictionary_size || dict_size > max_dictionary_size )
- { std::fputs( "Invalid dictionary size in member header.\n", stderr );
- return 2; }
+ { std::fputs( "Invalid dictionary size in member header.\n",
+ stderr ); return 2; }
LZ_decoder decoder( dict_size ); // decode LZMA stream
if( !decoder.decode_member() )
{ std::fputs( "Data error\n", stderr ); return 2; }
- Lzip_trailer trailer; // verify trailer
- for( int i = 0; i < 20; ++i ) trailer[i] = std::getc( stdin );
+ Lzip_trailer trailer; // check trailer
+ for( int i = 0; i < trailer_size; ++i ) trailer[i] = decoder.get_byte();
+ int retval = 0;
unsigned crc = 0;
- for( int i = 3; i >= 0; --i ) { crc <<= 8; crc += trailer[i]; }
+ for( int i = 3; i >= 0; --i ) crc = ( crc << 8 ) + trailer[i];
+ if( crc != decoder.crc() )
+ { std::fputs( "CRC mismatch\n", stderr ); retval = 2; }
+
unsigned long long data_size = 0;
- for( int i = 11; i >= 4; --i ) { data_size <<= 8; data_size += trailer[i]; }
- if( crc != decoder.crc() || data_size != decoder.data_position() )
- { std::fputs( "CRC error\n", stderr ); return 2; }
+ for( int i = 11; i >= 4; --i )
+ data_size = ( data_size << 8 ) + trailer[i];
+ if( data_size != decoder.data_position() )
+ { std::fputs( "Data size mismatch\n", stderr ); retval = 2; }
+
+ unsigned long long member_size = 0;
+ for( int i = 19; i >= 12; --i )
+ member_size = ( member_size << 8 ) + trailer[i];
+ if( member_size != decoder.member_position() )
+ { std::fputs( "Member size mismatch\n", stderr ); retval = 2; }
+ if( retval ) return retval;
}
if( std::fclose( stdout ) != 0 )
- { std::fprintf( stderr, "Error closing stdout: %s\n", std::strerror( errno ) );
- return 1; }
+ { std::fprintf( stderr, "Error closing stdout: %s\n",
+ std::strerror( errno ) ); return 1; }
return 0;
}
diff --git a/testsuite/check.sh b/testsuite/check.sh
index eb83163..b041fe8 100755
--- a/testsuite/check.sh
+++ b/testsuite/check.sh
@@ -1,9 +1,9 @@
#! /bin/sh
# check script for Lzd - Educational decompressor for the lzip format
-# Copyright (C) 2013-2019 Antonio Diaz Diaz.
+# Copyright (C) 2013-2024 Antonio Diaz Diaz.
#
# This script is free software: you have unlimited permission
-# to copy, distribute and modify it.
+# to copy, distribute, and modify it.
LC_ALL=C
export LC_ALL
@@ -30,6 +30,8 @@ cd "${objdir}"/tmp || framework_failure
in="${testdir}"/test.txt
in_lz="${testdir}"/test.txt.lz
+in_em="${testdir}"/test_em.txt.lz
+fox_lz="${testdir}"/fox.lz
fail=0
test_failed() { fail=1 ; printf " $1" ; [ -z "$2" ] || printf "($2)" ; }
@@ -38,36 +40,59 @@ printf "testing lzd-%s..." "$2"
"${LZIP}" < "${in}" 2> /dev/null
[ $? = 2 ] || test_failed $LINENO
-"${LZIP}" < "${in_lz}" > copy || test_failed $LINENO
-cmp "${in}" copy || test_failed $LINENO
+for i in "${in_lz}" "${in_em}" ; do
+ "${LZIP}" < "$i" > out || test_failed $LINENO "$i"
+ cmp "${in}" out || test_failed $LINENO "$i"
+done
cat "${in}" "${in}" > in2 || framework_failure
-cat "${in_lz}" "${in_lz}" > in2.lz || framework_failure
-"${LZIP}" < in2.lz > copy2 || test_failed $LINENO
-cmp in2 copy2 || test_failed $LINENO
+cat "${in_lz}" "${in_lz}" | "${LZIP}" > out2 || test_failed $LINENO
+cmp in2 out2 || test_failed $LINENO
+rm -f out2 || framework_failure
+
+cat "${in_lz}" "${in_lz}" > out2.lz || framework_failure
+printf "\ngarbage" >> out2.lz || framework_failure
+"${LZIP}" -d < out2.lz > out2 || test_failed $LINENO
+cmp in2 out2 || test_failed $LINENO
+rm -f in2 out2 out2.lz || framework_failure
printf "\ntesting bad input..."
+for i in fox_bm.lz fox_v2.lz fox_s11.lz fox_de20.lz \
+ fox_bcrc.lz fox_crc0.lz fox_das46.lz fox_mes81.lz ; do
+ "${LZIP}" < "${testdir}"/$i > /dev/null 2>&1
+ [ $? = 2 ] || test_failed $LINENO $i
+done
+
+"${LZIP}" < "${fox_lz}" > fox || test_failed $LINENO
+for i in fox_bcrc.lz fox_crc0.lz fox_das46.lz fox_mes81.lz ; do
+ "${LZIP}" < "${testdir}"/$i > out 2> /dev/null
+ [ $? = 2 ] || test_failed $LINENO $i
+ cmp fox out || test_failed $LINENO $i
+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
-cmp "${in}" copy || test_failed $LINENO
-rm -f copy ingin.lz || framework_failure
+"${LZIP}" -d < ingin.lz > out || test_failed $LINENO
+cmp "${in}" out || test_failed $LINENO
+rm -f out ingin.lz || framework_failure
echo
if [ ${fail} = 0 ] ; then
diff --git a/testsuite/fox.lz b/testsuite/fox.lz
new file mode 100644
index 0000000..509da82
--- /dev/null
+++ b/testsuite/fox.lz
Binary files differ
diff --git a/testsuite/fox_bcrc.lz b/testsuite/fox_bcrc.lz
new file mode 100644
index 0000000..8f6a7c4
--- /dev/null
+++ b/testsuite/fox_bcrc.lz
Binary files differ
diff --git a/testsuite/fox_bm.lz b/testsuite/fox_bm.lz
new file mode 100644
index 0000000..d71914f
--- /dev/null
+++ b/testsuite/fox_bm.lz
Binary files differ
diff --git a/testsuite/fox_crc0.lz b/testsuite/fox_crc0.lz
new file mode 100644
index 0000000..1abe926
--- /dev/null
+++ b/testsuite/fox_crc0.lz
Binary files differ
diff --git a/testsuite/fox_das46.lz b/testsuite/fox_das46.lz
new file mode 100644
index 0000000..43ed9f9
--- /dev/null
+++ b/testsuite/fox_das46.lz
Binary files differ
diff --git a/testsuite/fox_de20.lz b/testsuite/fox_de20.lz
new file mode 100644
index 0000000..10949d8
--- /dev/null
+++ b/testsuite/fox_de20.lz
Binary files differ
diff --git a/testsuite/fox_mes81.lz b/testsuite/fox_mes81.lz
new file mode 100644
index 0000000..d50ef2e
--- /dev/null
+++ b/testsuite/fox_mes81.lz
Binary files differ
diff --git a/testsuite/fox_s11.lz b/testsuite/fox_s11.lz
new file mode 100644
index 0000000..dca909c
--- /dev/null
+++ b/testsuite/fox_s11.lz
Binary files differ
diff --git a/testsuite/fox_v2.lz b/testsuite/fox_v2.lz
new file mode 100644
index 0000000..8620981
--- /dev/null
+++ b/testsuite/fox_v2.lz
Binary files differ
diff --git a/testsuite/test_em.txt.lz b/testsuite/test_em.txt.lz
new file mode 100644
index 0000000..7e96250
--- /dev/null
+++ b/testsuite/test_em.txt.lz
Binary files differ