1
0
Fork 0

Compare commits

...

10 commits

Author SHA1 Message Date
da26502706
Releasing debian version 1.14-1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2025-02-23 19:28:42 +01:00
98a23be90e
Correcting public-domain identifier in copyright.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2025-02-23 19:28:41 +01:00
3e788f38b7
Merging upstream version 1.14.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2025-02-23 19:28:41 +01:00
8e7b6e24fe
Releasing debian version 1.14~rc1-1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2025-02-23 19:28:28 +01:00
62d1763fed
Merging upstream version 1.14~rc1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2025-02-23 19:28:28 +01:00
093c647604
Releasing debian version 1.13-2.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2025-02-23 19:28:16 +01:00
40fb7ee662
Updating to standards-version 4.7.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2025-02-23 19:28:16 +01:00
b45ff9a2d4
Releasing debian version 1.13-1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2025-02-23 19:28:04 +01:00
eb1f08c2a1
Updating years in copyright for 2024.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2025-02-23 19:28:03 +01:00
59441602a2
Merging upstream version 1.13.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2025-02-23 19:28:03 +01:00
21 changed files with 343 additions and 249 deletions

View file

@ -1,8 +1,16 @@
2023-12-21 Antonio Diaz Diaz <antonio@gnu.org> 2025-01-07 Antonio Diaz Diaz <antonio@gnu.org>
* Version 1.13-rc1 released. * Version 1.14 released.
* main.c (decompress): Return 2 if empty member in multimember file.
(Pp_free): New function.
* check.sh: Use 'cp' instead of 'cat'.
2024-01-21 Antonio Diaz Diaz <antonio@gnu.org>
* Version 1.13 released.
* main.c: Reformat file diagnostics as 'PROGRAM: FILE: MESSAGE'. * main.c: Reformat file diagnostics as 'PROGRAM: FILE: MESSAGE'.
(show_option_error): New function showing argument and option name. (show_option_error): New function showing argument and option name.
(main): Make -o preserve date/mode/owner if 1 input file.
* lzip.h: Rename verify_* to check_*. * lzip.h: Rename verify_* to check_*.
* configure, Makefile.in: New variable 'MAKEINFO'. * configure, Makefile.in: New variable 'MAKEINFO'.
* INSTALL: Document use of CFLAGS+='--std=c99 -D_XOPEN_SOURCE=500'. * INSTALL: Document use of CFLAGS+='--std=c99 -D_XOPEN_SOURCE=500'.
@ -38,12 +46,12 @@
2018-02-04 Antonio Diaz Diaz <antonio@gnu.org> 2018-02-04 Antonio Diaz Diaz <antonio@gnu.org>
* Version 1.9 released. * Version 1.9 released.
* main.c: New option '--loose-trailing'. * New option '--loose-trailing'.
* main.c (decompress): Improve corrupt header detection to HD=3.
* Replace 'bits/byte' with inverse compression ratio in output. * Replace 'bits/byte' with inverse compression ratio in output.
* main.c: Show final diagnostic when testing multiple files. * main.c (decompress): Improve corrupt header detection to HD=3.
* main.c: Do not add a second .lz extension to the arg of -o. (main): Show final diagnostic when testing multiple files.
* main.c (lzip_decode): Show stored sizes also in hex. (set_c_outname): Do not add a second '.lz' to the arg of '-o'.
(lzip_decode): Show stored sizes also in hex.
Show dictionary size at verbosity level 4 (-vvvv). Show dictionary size at verbosity level 4 (-vvvv).
2017-04-12 Antonio Diaz Diaz <antonio@gnu.org> 2017-04-12 Antonio Diaz Diaz <antonio@gnu.org>
@ -57,10 +65,9 @@
* Version 1.7 released. * Version 1.7 released.
* main.c: New option '-a, --trailing-error'. * main.c: New option '-a, --trailing-error'.
* main.c (main): Delete '--output' file if infd is a terminal. * main.c (main): Delete '--output' file if infd is a terminal.
* main.c (main): Don't use stdin more than once. (main): Don't use stdin more than once.
* configure: Avoid warning on some shells when testing for gcc. * configure: Avoid warning on some shells when testing for gcc.
* check.sh: A POSIX shell is required to run the tests. * check.sh: Require a POSIX shell. Don't check error messages.
* check.sh: Don't check error messages.
2015-05-26 Antonio Diaz Diaz <antonio@gnu.org> 2015-05-26 Antonio Diaz Diaz <antonio@gnu.org>
@ -77,16 +84,16 @@
2013-05-27 Antonio Diaz Diaz <antonio@gnu.org> 2013-05-27 Antonio Diaz Diaz <antonio@gnu.org>
* Version 1.4 released. * Version 1.4 released.
* Decompression time has been reduced by 5%.
* main.c: New options '-f, --force', '-F, --recompress', * main.c: New options '-f, --force', '-F, --recompress',
'-k, --keep', and '-o, --output'. '-k, --keep', and '-o, --output'.
* main.c: Accept more than one file in command line. Accept more than one file in command line.
* Decompression time has been reduced by 5%. (main): '--test' no longer needs '/dev/null'.
* main.c: '--test' no longer needs '/dev/null'. (main): Fix return value of '-d' and '-t' in case of data error.
* Fix return value of '-d' and '-t' in case of data error. Change info shown at verbosity levels 2 and 3.
* main.c: Change info shown at verbosity levels 2 and 3. (main): Ignore option '-n, --threads' for compatibility with plzip.
* Ignore option '-n, --threads' for compatibility with plzip.
* configure: Options now accept a separate argument. * configure: Options now accept a separate argument.
* configure: Rename 'datadir' to 'datarootdir'. Rename 'datadir' to 'datarootdir'.
* Makefile.in: New targets 'install-as-lzip' and 'install-bin'. * Makefile.in: New targets 'install-as-lzip' and 'install-bin'.
2012-01-03 Antonio Diaz Diaz <ant_diaz@teleline.es> 2012-01-03 Antonio Diaz Diaz <ant_diaz@teleline.es>
@ -94,7 +101,7 @@
* Version 1.3 released. * Version 1.3 released.
* Small change in '--help' output and man page. * Small change in '--help' output and man page.
* Change quote characters in messages as advised by GNU Standards. * Change quote characters in messages as advised by GNU Standards.
* main.c: Set stdin/stdout in binary mode on OS2. * main.c (main): Set stdin/stdout in binary mode on OS2.
2011-01-05 Antonio Diaz Diaz <ant_diaz@teleline.es> 2011-01-05 Antonio Diaz Diaz <ant_diaz@teleline.es>
@ -118,8 +125,7 @@
* Using LZMA SDK 9.10 (public domain) from Igor Pavlov. * Using LZMA SDK 9.10 (public domain) from Igor Pavlov.
Copyright (C) 2010-2023 Antonio Diaz Diaz. Copyright (C) 2010-2025 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
but just in case, you have unlimited permission to copy, distribute, and in case, you have unlimited permission to copy, distribute, and modify it.
modify it.

View file

@ -3,7 +3,8 @@ Requirements
You will need a C99 compiler. (gcc 3.3.6 or newer is recommended). You will need a C99 compiler. (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 I use gcc 6.1.0 and 3.3.6, but the code should compile with any standards
compliant compiler. compliant compiler.
Gcc is available at http://gcc.gnu.org. Gcc is available at http://gcc.gnu.org
Lzip is available at http://www.nongnu.org/lzip/lzip.html
The operating system must allow signal handlers read access to objects with The operating system must allow signal handlers read access to objects with
static storage duration so that the cleanup handler for Control-C can delete static storage duration so that the cleanup handler for Control-C can delete
@ -74,7 +75,7 @@ After running 'configure', you can run 'make' and 'make install' as
explained above. explained above.
Copyright (C) 2010-2023 Antonio Diaz Diaz. Copyright (C) 2010-2025 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

@ -716,8 +716,8 @@ static bool LzmaDec_DecodeToDic(CLzmaDec *p, uint32_t dicLimit,
*status = LZMA_STATUS_NEEDS_MORE_INPUT; *status = LZMA_STATUS_NEEDS_MORE_INPUT;
return true; return true;
} }
if (p->tempBuf[0] != 0) /* check first byte of the LZMA stream */
return false; if (p->tempBuf[0] != 0) return false;
LzmaDec_InitRc(p, p->tempBuf); LzmaDec_InitRc(p, p->tempBuf);
p->tempBufSize = 0; p->tempBufSize = 0;

View file

@ -2,8 +2,8 @@
DISTNAME = $(pkgname)-$(pkgversion) DISTNAME = $(pkgname)-$(pkgversion)
INSTALL = install INSTALL = install
INSTALL_PROGRAM = $(INSTALL) -m 755 INSTALL_PROGRAM = $(INSTALL) -m 755
INSTALL_DATA = $(INSTALL) -m 644
INSTALL_DIR = $(INSTALL) -d -m 755 INSTALL_DIR = $(INSTALL) -d -m 755
INSTALL_DATA = $(INSTALL) -m 644
SHELL = /bin/sh SHELL = /bin/sh
CAN_RUN_INSTALLINFO = $(SHELL) -c "install-info --version" > /dev/null 2>&1 CAN_RUN_INSTALLINFO = $(SHELL) -c "install-info --version" > /dev/null 2>&1
@ -30,7 +30,8 @@ main.o : main.c
# prevent 'make' from trying to remake source files # prevent 'make' from trying to remake source files
$(VPATH)/configure $(VPATH)/Makefile.in $(VPATH)/doc/$(pkgname).texi : ; $(VPATH)/configure $(VPATH)/Makefile.in $(VPATH)/doc/$(pkgname).texi : ;
%.h %.c : ; MAKEFLAGS += -r
.SUFFIXES :
$(objs) : Makefile $(objs) : Makefile
carg_parser.o : carg_parser.h carg_parser.o : carg_parser.h
@ -125,8 +126,7 @@ dist : doc
$(DISTNAME)/testsuite/fox.lz \ $(DISTNAME)/testsuite/fox.lz \
$(DISTNAME)/testsuite/fox_*.lz \ $(DISTNAME)/testsuite/fox_*.lz \
$(DISTNAME)/testsuite/test.txt.lz \ $(DISTNAME)/testsuite/test.txt.lz \
$(DISTNAME)/testsuite/test.txt.lzma \ $(DISTNAME)/testsuite/test.txt.lzma
$(DISTNAME)/testsuite/test_em.txt.lz
rm -f $(DISTNAME) rm -f $(DISTNAME)
lzip -v -9 $(DISTNAME).tar lzip -v -9 $(DISTNAME).tar

14
NEWS
View file

@ -1,12 +1,4 @@
Changes in version 1.13: Changes in version 1.14:
File diagnostics have been reformatted as 'PROGRAM: FILE: MESSAGE'. pdlzip now exits with error status 2 if any empty member is found in a
multimember file.
Diagnostics caused by invalid arguments to command-line options now show the
argument and the name of the option.
The variable MAKEINFO has been added to configure and Makefile.in.
It has been documented in INSTALL that when choosing a C standard, the POSIX
features need to be enabled explicitly:
./configure CFLAGS+='--std=c99 -D_XOPEN_SOURCE=500'

47
README
View file

@ -1,30 +1,31 @@
See the file INSTALL for compilation and installation instructions.
Description Description
Pdlzip is a permissively licensed implementation of the lzip data Pdlzip is a permissively licensed implementation of the lzip data
compressor, intended for those who can't distribute (or even use) GPL compressor, intended for those who can't distribute (or even use) GPL
licensed Free Software. The name of pdlzip comes from 'public domain lzip'. licensed Free Software. The name of pdlzip comes from 'public domain lzip'.
Pdlzip is written in C and is (hope)fully compatible with lzip 1.4 or newer. Pdlzip is written in C.
Lzip is a lossless data compressor with a user interface similar to the one Lzip is a lossless data compressor with a user interface similar to the one
of gzip or bzip2. Lzip uses a simplified form of the 'Lempel-Ziv-Markov of gzip or bzip2. Lzip uses a simplified form of LZMA (Lempel-Ziv-Markov
chain-Algorithm' (LZMA) stream format to maximize interoperability. The chain-Algorithm) designed to achieve complete interoperability between
maximum dictionary size is 512 MiB so that any lzip file can be decompressed implementations. The maximum dictionary size is 512 MiB so that any lzip
on 32-bit machines. Lzip provides accurate and robust 3-factor integrity file can be decompressed on 32-bit machines. Lzip provides accurate and
checking. Lzip can compress about as fast as gzip (lzip -0) or compress most robust 3-factor integrity checking. 'lzip -0' compresses about as fast as
files more than bzip2 (lzip -9). Decompression speed is intermediate between gzip, while 'lzip -9' compresses most files more than bzip2. Decompression
gzip and bzip2. Lzip is better than gzip and bzip2 from a data recovery speed is intermediate between gzip and bzip2. Lzip provides better data
perspective. Lzip has been designed, written, and tested with great care to recovery capabilities than gzip and bzip2. Lzip has been designed, written,
replace gzip and bzip2 as the standard general-purpose compressed format for and tested with great care to replace gzip and bzip2 as general-purpose
Unix-like systems. compressed format for Unix-like systems.
The lzip file format is designed for data sharing and long-term archiving, The lzip file format is designed for data sharing and long-term archiving,
taking into account both data integrity and decoder availability: taking into account both data integrity and decoder availability:
* The lzip format provides very safe integrity checking and some data * The program lziprecover can repair bit flip errors (one of the most
recovery means. The program lziprecover can repair bit flip errors common forms of data corruption) in lzip files, and provides data
(one of the most common forms of data corruption) in lzip files, and recovery capabilities, including error-checked merging of damaged
provides data recovery capabilities, including error-checked merging copies of a file.
of damaged copies of a file.
* The lzip format is as simple as possible (but not simpler). The lzip * 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 manual provides the source code of a simple decompressor along with a
@ -50,18 +51,14 @@ without recompressing.
Pdlzip includes public domain compression/decompression code from the LZMA Pdlzip includes public domain compression/decompression code from the LZMA
SDK (Software Development Kit) written by Igor Pavlov. SDK (Software Development Kit) written by Igor Pavlov.
I would not write non-copylefted software unless it is too simple to be Pdlzip uses Arg_parser for command-line argument parsing:
worth copylefting it, but one of the uses of the lzip format is the http://www.nongnu.org/arg-parser/arg_parser.html
interchange of information, and it is therefore desirable that even the
users of the most non-free platforms can share lzip files with everybody
else.
Copyright (C) 2010-2023 Antonio Diaz Diaz. Copyright (C) 2010-2025 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.
The file Makefile.in is a data file used by configure to produce the The file Makefile.in is a data file used by configure to produce the Makefile.
Makefile. It has the same copyright owner and permissions that configure It has the same copyright owner and permissions that configure itself.
itself.

View file

@ -1,5 +1,5 @@
/* Arg_parser - POSIX/GNU command-line argument parser. (C version) /* Arg_parser - POSIX/GNU command-line argument parser. (C version)
Copyright (C) 2006-2023 Antonio Diaz Diaz. Copyright (C) 2006-2025 Antonio Diaz Diaz.
This library is free software. Redistribution and use in source and This library is free software. Redistribution and use in source and
binary forms, with or without modification, are permitted provided binary forms, with or without modification, are permitted provided
@ -32,15 +32,15 @@ static void * ap_resize_buffer( void * buf, const int min_size )
} }
static char push_back_record( struct Arg_parser * const ap, const int code, static char push_back_record( Arg_parser * const ap, const int code,
const char * const long_name, const char * const long_name,
const char * const argument ) const char * const argument )
{ {
struct ap_Record * p; ap_Record * p;
void * tmp = ap_resize_buffer( ap->data, void * tmp = ap_resize_buffer( ap->data,
( ap->data_size + 1 ) * sizeof (struct ap_Record) ); ( ap->data_size + 1 ) * sizeof (ap_Record) );
if( !tmp ) return 0; if( !tmp ) return 0;
ap->data = (struct ap_Record *)tmp; ap->data = (ap_Record *)tmp;
p = &(ap->data[ap->data_size]); p = &(ap->data[ap->data_size]);
p->code = code; p->code = code;
if( long_name ) if( long_name )
@ -71,7 +71,7 @@ static char push_back_record( struct Arg_parser * const ap, const int code,
} }
static char add_error( struct Arg_parser * const ap, const char * const msg ) static char add_error( Arg_parser * const ap, const char * const msg )
{ {
const int len = strlen( msg ); const int len = strlen( msg );
void * tmp = ap_resize_buffer( ap->error, ap->error_size + len + 1 ); void * tmp = ap_resize_buffer( ap->error, ap->error_size + len + 1 );
@ -83,7 +83,7 @@ static char add_error( struct Arg_parser * const ap, const char * const msg )
} }
static void free_data( struct Arg_parser * const ap ) static void free_data( Arg_parser * const ap )
{ {
int i; int i;
for( i = 0; i < ap->data_size; ++i ) for( i = 0; i < ap->data_size; ++i )
@ -94,10 +94,9 @@ static void free_data( struct Arg_parser * const ap )
/* Return 0 only if out of memory. */ /* Return 0 only if out of memory. */
static char parse_long_option( struct Arg_parser * const ap, static char parse_long_option( Arg_parser * const ap,
const char * const opt, const char * const arg, const char * const opt, const char * const arg,
const struct ap_Option options[], const ap_Option options[], int * const argindp )
int * const argindp )
{ {
unsigned len; unsigned len;
int index = -1, i; int index = -1, i;
@ -148,21 +147,21 @@ static char parse_long_option( struct Arg_parser * const ap,
add_error( ap, "' requires an argument" ); add_error( ap, "' requires an argument" );
return 1; return 1;
} }
return push_back_record( ap, options[index].code, return push_back_record( ap, options[index].code, options[index].long_name,
options[index].long_name, &opt[len+3] ); &opt[len+3] ); /* argument may be empty */
} }
if( options[index].has_arg == ap_yes ) if( options[index].has_arg == ap_yes || options[index].has_arg == ap_yme )
{ {
if( !arg || !arg[0] ) if( !arg || ( options[index].has_arg == ap_yes && !arg[0] ) )
{ {
add_error( ap, "option '--" ); add_error( ap, options[index].long_name ); add_error( ap, "option '--" ); add_error( ap, options[index].long_name );
add_error( ap, "' requires an argument" ); add_error( ap, "' requires an argument" );
return 1; return 1;
} }
++*argindp; ++*argindp;
return push_back_record( ap, options[index].code, return push_back_record( ap, options[index].code, options[index].long_name,
options[index].long_name, arg ); arg ); /* argument may be empty */
} }
return push_back_record( ap, options[index].code, return push_back_record( ap, options[index].code,
@ -171,10 +170,9 @@ static char parse_long_option( struct Arg_parser * const ap,
/* Return 0 only if out of memory. */ /* Return 0 only if out of memory. */
static char parse_short_option( struct Arg_parser * const ap, static char parse_short_option( Arg_parser * const ap,
const char * const opt, const char * const arg, const char * const opt, const char * const arg,
const struct ap_Option options[], const ap_Option options[], int * const argindp )
int * const argindp )
{ {
int cind = 1; /* character index in opt */ int cind = 1; /* character index in opt */
@ -204,15 +202,15 @@ static char parse_short_option( struct Arg_parser * const ap,
if( !push_back_record( ap, c, 0, &opt[cind] ) ) return 0; if( !push_back_record( ap, c, 0, &opt[cind] ) ) return 0;
++*argindp; cind = 0; ++*argindp; cind = 0;
} }
else if( options[index].has_arg == ap_yes ) else if( options[index].has_arg == ap_yes || options[index].has_arg == ap_yme )
{ {
if( !arg || !arg[0] ) if( !arg || ( options[index].has_arg == ap_yes && !arg[0] ) )
{ {
add_error( ap, "option requires an argument -- '" ); add_error( ap, "option requires an argument -- '" );
add_error( ap, code_str ); add_error( ap, "'" ); add_error( ap, code_str ); add_error( ap, "'" );
return 1; return 1;
} }
++*argindp; cind = 0; ++*argindp; cind = 0; /* argument may be empty */
if( !push_back_record( ap, c, 0, arg ) ) return 0; if( !push_back_record( ap, c, 0, arg ) ) return 0;
} }
else if( !push_back_record( ap, c, 0, 0 ) ) return 0; else if( !push_back_record( ap, c, 0, 0 ) ) return 0;
@ -221,9 +219,9 @@ static char parse_short_option( struct Arg_parser * const ap,
} }
char ap_init( struct Arg_parser * const ap, char ap_init( Arg_parser * const ap,
const int argc, const char * const argv[], const int argc, const char * const argv[],
const struct ap_Option options[], const char in_order ) const ap_Option options[], const char in_order )
{ {
const char ** non_options = 0; /* skipped non-options */ const char ** non_options = 0; /* skipped non-options */
int non_options_size = 0; /* number of skipped non-options */ int non_options_size = 0; /* number of skipped non-options */
@ -282,7 +280,7 @@ out: if( non_options ) free( non_options );
} }
void ap_free( struct Arg_parser * const ap ) void ap_free( Arg_parser * const ap )
{ {
free_data( ap ); free_data( ap );
if( ap->error ) { free( ap->error ); ap->error = 0; } if( ap->error ) { free( ap->error ); ap->error = 0; }
@ -290,29 +288,25 @@ void ap_free( struct Arg_parser * const ap )
} }
const char * ap_error( const struct Arg_parser * const ap ) const char * ap_error( const Arg_parser * const ap ) { return ap->error; }
{ return ap->error; }
int ap_arguments( const Arg_parser * const ap ) { return ap->data_size; }
int ap_arguments( const struct Arg_parser * const ap ) int ap_code( const Arg_parser * const ap, const int i )
{ return ap->data_size; }
int ap_code( const struct Arg_parser * const ap, const int i )
{ {
if( i < 0 || i >= ap_arguments( ap ) ) return 0; if( i < 0 || i >= ap_arguments( ap ) ) return 0;
return ap->data[i].code; return ap->data[i].code;
} }
const char * ap_parsed_name( const struct Arg_parser * const ap, const int i ) const char * ap_parsed_name( const Arg_parser * const ap, const int i )
{ {
if( i < 0 || i >= ap_arguments( ap ) || !ap->data[i].parsed_name ) return ""; if( i < 0 || i >= ap_arguments( ap ) || !ap->data[i].parsed_name ) return "";
return ap->data[i].parsed_name; return ap->data[i].parsed_name;
} }
const char * ap_argument( const struct Arg_parser * const ap, const int i ) const char * ap_argument( const Arg_parser * const ap, const int i )
{ {
if( i < 0 || i >= ap_arguments( ap ) || !ap->data[i].argument ) return ""; if( i < 0 || i >= ap_arguments( ap ) || !ap->data[i].argument ) return "";
return ap->data[i].argument; return ap->data[i].argument;

View file

@ -1,5 +1,5 @@
/* Arg_parser - POSIX/GNU command-line argument parser. (C version) /* Arg_parser - POSIX/GNU command-line argument parser. (C version)
Copyright (C) 2006-2023 Antonio Diaz Diaz. Copyright (C) 2006-2025 Antonio Diaz Diaz.
This library is free software. Redistribution and use in source and This library is free software. Redistribution and use in source and
binary forms, with or without modification, are permitted provided binary forms, with or without modification, are permitted provided
@ -37,60 +37,65 @@
The argument '--' terminates all options; any following arguments are The argument '--' terminates all options; any following arguments are
treated as non-option arguments, even if they begin with a hyphen. treated as non-option arguments, even if they begin with a hyphen.
The syntax for optional option arguments is '-<short_option><argument>' The syntax of options with an optional argument is
(without whitespace), or '--<long_option>=<argument>'. '-<short_option><argument>' (without whitespace), or
'--<long_option>=<argument>'.
The syntax of options with an empty argument is '-<short_option> ""',
'--<long_option> ""', or '--<long_option>=""'.
*/ */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
enum ap_Has_arg { ap_no, ap_yes, ap_maybe }; /* ap_yme = yes but maybe empty */
typedef enum ap_Has_arg { ap_no, ap_yes, ap_maybe, ap_yme } ap_Has_arg;
struct ap_Option typedef struct ap_Option
{ {
int code; /* Short option letter or code ( code != 0 ) */ int code; /* Short option letter or code ( code != 0 ) */
const char * long_name; /* Long option name (maybe null) */ const char * long_name; /* Long option name (maybe null) */
enum ap_Has_arg has_arg; ap_Has_arg has_arg;
}; } ap_Option;
struct ap_Record typedef struct ap_Record
{ {
int code; int code;
char * parsed_name; char * parsed_name;
char * argument; char * argument;
}; } ap_Record;
struct Arg_parser typedef struct Arg_parser
{ {
struct ap_Record * data; ap_Record * data;
char * error; char * error;
int data_size; int data_size;
int error_size; int error_size;
}; } Arg_parser;
char ap_init( struct Arg_parser * const ap, char ap_init( Arg_parser * const ap,
const int argc, const char * const argv[], const int argc, const char * const argv[],
const struct ap_Option options[], const char in_order ); const ap_Option options[], const char in_order );
void ap_free( struct Arg_parser * const ap ); void ap_free( Arg_parser * const ap );
const char * ap_error( const struct Arg_parser * const ap ); const char * ap_error( const Arg_parser * const ap );
/* The number of arguments parsed. May be different from argc. */ /* The number of arguments parsed. May be different from argc. */
int ap_arguments( const struct Arg_parser * const ap ); int ap_arguments( const Arg_parser * const ap );
/* If ap_code( i ) is 0, ap_argument( i ) is a non-option. /* If ap_code( i ) is 0, ap_argument( i ) is a non-option.
Else ap_argument( i ) is the option's argument (or empty). */ Else ap_argument( i ) is the option's argument (or empty). */
int ap_code( const struct Arg_parser * const ap, const int i ); int ap_code( const Arg_parser * const ap, const int i );
/* Full name of the option parsed (short or long). */ /* Full name of the option parsed (short or long). */
const char * ap_parsed_name( const struct Arg_parser * const ap, const int i ); const char * ap_parsed_name( const Arg_parser * const ap, const int i );
const char * ap_argument( const struct Arg_parser * const ap, const int i ); const char * ap_argument( const Arg_parser * const ap, const int i );
#ifdef __cplusplus #ifdef __cplusplus
} }

8
configure vendored
View file

@ -1,12 +1,12 @@
#! /bin/sh #! /bin/sh
# configure script for Pdlzip - LZMA lossless data compressor # configure script for Pdlzip - LZMA lossless data compressor
# Copyright (C) 2010-2023 Antonio Diaz Diaz. # Copyright (C) 2010-2025 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=pdlzip pkgname=pdlzip
pkgversion=1.13-rc1 pkgversion=1.14
progname=pdlzip progname=pdlzip
srctrigger=doc/${progname}.1 srctrigger=doc/${progname}.1
@ -109,7 +109,7 @@ while [ $# != 0 ] ; do
exit 1 ;; exit 1 ;;
esac esac
# Check if the option took a separate argument # Check whether the option took a separate argument
if [ "${arg2}" = yes ] ; then if [ "${arg2}" = yes ] ; then
if [ $# != 0 ] ; then args="${args} \"$1\"" ; shift if [ $# != 0 ] ; then args="${args} \"$1\"" ; shift
else echo "configure: Missing argument to '${option}'" 1>&2 else echo "configure: Missing argument to '${option}'" 1>&2
@ -171,7 +171,7 @@ echo "MAKEINFO = ${MAKEINFO}"
rm -f Makefile rm -f Makefile
cat > Makefile << EOF cat > Makefile << EOF
# Makefile for Pdlzip - LZMA lossless data compressor # Makefile for Pdlzip - LZMA lossless data compressor
# Copyright (C) 2010-2023 Antonio Diaz Diaz. # Copyright (C) 2010-2025 Antonio Diaz Diaz.
# This file was generated automatically by configure. Don't edit. # This file was generated automatically by configure. Don't edit.
# #
# This Makefile is free software: you have unlimited permission # This Makefile is free software: you have unlimited permission

30
debian/changelog vendored
View file

@ -1,3 +1,33 @@
pdlzip (1.14-1) sid; urgency=medium
* Uploading to sid.
* Merging upstream version 1.14.
* Correcting public-domain identifier in copyright.
-- Daniel Baumann <daniel.baumann@progress-linux.org> Tue, 14 Jan 2025 11:06:12 +0100
pdlzip (1.14~rc1-1) sid; urgency=medium
* Uploading to sid.
* Merging upstream version 1.14~rc1.
-- Daniel Baumann <daniel.baumann@progress-linux.org> Sun, 10 Nov 2024 09:40:36 +0100
pdlzip (1.13-2) sid; urgency=medium
* Uploading to sid.
* Updating to standards-version 4.7.0.
-- Daniel Baumann <daniel.baumann@progress-linux.org> Thu, 25 Jul 2024 06:44:16 +0200
pdlzip (1.13-1) sid; urgency=medium
* Uploading to sid.
* Merging upstream version 1.13.
* Updating years in copyright for 2024.
-- Daniel Baumann <daniel.baumann@progress-linux.org> Wed, 31 Jan 2024 06:33:48 +0100
pdlzip (1.13~rc1-1) sid; urgency=medium pdlzip (1.13~rc1-1) sid; urgency=medium
* Uploading to sid. * Uploading to sid.

2
debian/control vendored
View file

@ -5,7 +5,7 @@ Maintainer: Daniel Baumann <daniel.baumann@progress-linux.org>
Build-Depends: Build-Depends:
debhelper-compat (= 13), debhelper-compat (= 13),
Rules-Requires-Root: no Rules-Requires-Root: no
Standards-Version: 4.6.2 Standards-Version: 4.7.0
Homepage: http://www.nongnu.org/lzip/pdlzip.html Homepage: http://www.nongnu.org/lzip/pdlzip.html
Vcs-Browser: https://git.progress-linux.org/users/daniel.baumann/debian/packages/pdlzip Vcs-Browser: https://git.progress-linux.org/users/daniel.baumann/debian/packages/pdlzip
Vcs-Git: https://git.progress-linux.org/users/daniel.baumann/debian/packages/pdlzip Vcs-Git: https://git.progress-linux.org/users/daniel.baumann/debian/packages/pdlzip

6
debian/copyright vendored
View file

@ -4,12 +4,12 @@ Upstream-Contact: lzip-bug@nongnu.org
Source: https://download.savannah.gnu.org/releases/lzip/ Source: https://download.savannah.gnu.org/releases/lzip/
Files: * Files: *
Copyright: 2010-2022 Antonio Diaz Diaz <ant_diaz@teleline.es> Copyright: 2010-2024 Antonio Diaz Diaz <ant_diaz@teleline.es>
Igor Pavlov Igor Pavlov
License: PD License: public-domain
Files: debian/* Files: debian/*
Copyright: 2009-2022 Daniel Baumann <daniel.baumann@progress-linux.org> Copyright: 2009-2024 Daniel Baumann <daniel.baumann@progress-linux.org>
License: BSD-2 License: BSD-2
License: BSD-2 License: BSD-2

View file

@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.2. .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.2.
.TH PDLZIP "1" "December 2023" "pdlzip 1.13-rc1" "User Commands" .TH PDLZIP "1" "January 2025" "pdlzip 1.14" "User Commands"
.SH NAME .SH NAME
pdlzip \- reduces the size of files pdlzip \- reduces the size of files
.SH SYNOPSIS .SH SYNOPSIS
@ -9,19 +9,19 @@ pdlzip \- reduces the size of files
Pdlzip is a permissively licensed implementation of the lzip data Pdlzip is a permissively licensed implementation of the lzip data
compressor, intended for those who can't distribute (or even use) GPL compressor, intended for those who can't distribute (or even use) GPL
licensed Free Software. The name of pdlzip comes from 'public domain lzip'. licensed Free Software. The name of pdlzip comes from 'public domain lzip'.
Pdlzip is written in C and is (hope)fully compatible with lzip 1.4 or newer. Pdlzip is written in C.
.PP .PP
Lzip is a lossless data compressor with a user interface similar to the one Lzip is a lossless data compressor with a user interface similar to the one
of gzip or bzip2. Lzip uses a simplified form of the 'Lempel\-Ziv\-Markov of gzip or bzip2. Lzip uses a simplified form of LZMA (Lempel\-Ziv\-Markov
chain\-Algorithm' (LZMA) stream format to maximize interoperability. The chain\-Algorithm) designed to achieve complete interoperability between
maximum dictionary size is 512 MiB so that any lzip file can be decompressed implementations. The maximum dictionary size is 512 MiB so that any lzip
on 32\-bit machines. Lzip provides accurate and robust 3\-factor integrity file can be decompressed on 32\-bit machines. Lzip provides accurate and
checking. Lzip can compress about as fast as gzip (lzip \fB\-0\fR) or compress most robust 3\-factor integrity checking. 'lzip \fB\-0\fR' compresses about as fast as
files more than bzip2 (lzip \fB\-9\fR). Decompression speed is intermediate between gzip, while 'lzip \fB\-9\fR' compresses most files more than bzip2. Decompression
gzip and bzip2. Lzip is better than gzip and bzip2 from a data recovery speed is intermediate between gzip and bzip2. Lzip provides better data
perspective. Lzip has been designed, written, and tested with great care to recovery capabilities than gzip and bzip2. Lzip has been designed, written,
replace gzip and bzip2 as the standard general\-purpose compressed format for and tested with great care to replace gzip and bzip2 as general\-purpose
Unix\-like systems. compressed format for Unix\-like systems.
.PP .PP
Pdlzip is also able to decompress legacy lzma\-alone (.lzma) files. Pdlzip is also able to decompress legacy lzma\-alone (.lzma) files.
Lzma\-alone is a very bad format; it is essentially a raw LZMA stream. Lzma\-alone is a very bad format; it is essentially a raw LZMA stream.
@ -112,7 +112,7 @@ Report bugs to lzip\-bug@nongnu.org
.br .br
Pdlzip home page: http://www.nongnu.org/lzip/pdlzip.html Pdlzip home page: http://www.nongnu.org/lzip/pdlzip.html
.SH COPYRIGHT .SH COPYRIGHT
Copyright \(co 2023 Antonio Diaz Diaz. Copyright \(co 2025 Antonio Diaz Diaz.
Public Domain 2009 Igor Pavlov. Public Domain 2009 Igor Pavlov.
License 2\-clause BSD. License 2\-clause BSD.
.br .br

15
lzip.h
View file

@ -1,5 +1,5 @@
/* Pdlzip - LZMA lossless data compressor /* Pdlzip - LZMA lossless data compressor
Copyright (C) 2010-2023 Antonio Diaz Diaz. Copyright (C) 2010-2025 Antonio Diaz Diaz.
This program is free software. Redistribution and use in source and This program is free software. Redistribution and use in source and
binary forms, with or without modification, are permitted provided binary forms, with or without modification, are permitted provided
@ -188,11 +188,22 @@ static inline void Lt_set_member_size( Lzip_trailer data, unsigned long long sz
{ int i; for( i = 12; i <= 19; ++i ) { data[i] = (uint8_t)sz; sz >>= 8; } } { int i; for( i = 12; i <= 19; ++i ) { data[i] = (uint8_t)sz; sz >>= 8; } }
typedef struct Cl_options /* command-line options */
{
bool ignore_trailing;
bool loose_trailing;
} Cl_options;
static inline void Cl_options_init( Cl_options * cl_opts )
{ cl_opts->ignore_trailing = true; cl_opts->loose_trailing = false; }
static inline void set_retval( int * retval, const int new_val ) static inline void set_retval( int * retval, const int new_val )
{ if( *retval < new_val ) *retval = new_val; } { if( *retval < new_val ) *retval = new_val; }
static const char * const trailing_msg = "Trailing data not allowed."; static const char * const empty_msg = "Empty member not allowed.";
static const char * const mem_msg = "Not enough memory."; static const char * const mem_msg = "Not enough memory.";
static const char * const trailing_msg = "Trailing data not allowed.";
/* defined in main.c */ /* defined in main.c */
extern int verbosity; extern int verbosity;

151
main.c
View file

@ -1,6 +1,6 @@
/* Pdlzip - LZMA lossless data compressor /* Pdlzip - LZMA lossless data compressor
2009-08-14 : Igor Pavlov : Public domain 2009-08-14 : Igor Pavlov : Public domain
Copyright (C) 2010-2023 Antonio Diaz Diaz. Copyright (C) 2010-2025 Antonio Diaz Diaz.
This program is free software. Redistribution and use in source and This program is free software. Redistribution and use in source and
binary forms, with or without modification, are permitted provided binary forms, with or without modification, are permitted provided
@ -28,7 +28,7 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <limits.h> /* SSIZE_MAX */ #include <limits.h> /* CHAR_BIT, SSIZE_MAX */
#include <signal.h> #include <signal.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> /* SIZE_MAX */ #include <stdint.h> /* SIZE_MAX */
@ -85,7 +85,7 @@ static void show_file_error( const char * const filename,
static void internal_error( const char * const msg ); static void internal_error( const char * const msg );
static const char * const program_name = "pdlzip"; static const char * const program_name = "pdlzip";
static const char * const program_year = "2023"; static const char * const program_year = "2025";
static const char * invocation_name = "pdlzip"; /* default value */ static const char * invocation_name = "pdlzip"; /* default value */
static const struct { const char * from; const char * to; } known_extensions[] = { static const struct { const char * from; const char * to; } known_extensions[] = {
@ -94,13 +94,13 @@ static const struct { const char * from; const char * to; } known_extensions[] =
{ ".lzma", "" }, { ".lzma", "" },
{ 0, 0 } }; { 0, 0 } };
struct Lzma_options typedef struct Lzma_options
{ {
int dictionary_size; /* 4 KiB .. 512 MiB */ int dictionary_size; /* 4 KiB .. 512 MiB */
int match_len_limit; /* 5 .. 273 */ int match_len_limit; /* 5 .. 273 */
}; } Lzma_options;
enum Mode { m_compress, m_decompress, m_test }; typedef enum Mode { m_compress, m_decompress, m_test } Mode;
/* Variables used in signal handler context. /* Variables used in signal handler context.
They are not declared volatile because the handler never returns. */ They are not declared volatile because the handler never returns. */
@ -114,18 +114,18 @@ static void show_help( void )
printf( "Pdlzip is a permissively licensed implementation of the lzip data\n" printf( "Pdlzip is a permissively licensed implementation of the lzip data\n"
"compressor, intended for those who can't distribute (or even use) GPL\n" "compressor, intended for those who can't distribute (or even use) GPL\n"
"licensed Free Software. The name of pdlzip comes from 'public domain lzip'.\n" "licensed Free Software. The name of pdlzip comes from 'public domain lzip'.\n"
"Pdlzip is written in C and is (hope)fully compatible with lzip 1.4 or newer.\n" "Pdlzip is written in C.\n"
"\nLzip is a lossless data compressor with a user interface similar to the one\n" "\nLzip is a lossless data compressor with a user interface similar to the one\n"
"of gzip or bzip2. Lzip uses a simplified form of the 'Lempel-Ziv-Markov\n" "of gzip or bzip2. Lzip uses a simplified form of LZMA (Lempel-Ziv-Markov\n"
"chain-Algorithm' (LZMA) stream format to maximize interoperability. The\n" "chain-Algorithm) designed to achieve complete interoperability between\n"
"maximum dictionary size is 512 MiB so that any lzip file can be decompressed\n" "implementations. The maximum dictionary size is 512 MiB so that any lzip\n"
"on 32-bit machines. Lzip provides accurate and robust 3-factor integrity\n" "file can be decompressed on 32-bit machines. Lzip provides accurate and\n"
"checking. Lzip can compress about as fast as gzip (lzip -0) or compress most\n" "robust 3-factor integrity checking. 'lzip -0' compresses about as fast as\n"
"files more than bzip2 (lzip -9). Decompression speed is intermediate between\n" "gzip, while 'lzip -9' compresses most files more than bzip2. Decompression\n"
"gzip and bzip2. Lzip is better than gzip and bzip2 from a data recovery\n" "speed is intermediate between gzip and bzip2. Lzip provides better data\n"
"perspective. Lzip has been designed, written, and tested with great care to\n" "recovery capabilities than gzip and bzip2. Lzip has been designed, written,\n"
"replace gzip and bzip2 as the standard general-purpose compressed format for\n" "and tested with great care to replace gzip and bzip2 as general-purpose\n"
"Unix-like systems.\n" "compressed format for Unix-like systems.\n"
"\nPdlzip is also able to decompress legacy lzma-alone (.lzma) files.\n" "\nPdlzip is also able to decompress legacy lzma-alone (.lzma) files.\n"
"Lzma-alone is a very bad format; it is essentially a raw LZMA stream.\n" "Lzma-alone is a very bad format; it is essentially a raw LZMA stream.\n"
"If you keep any lzma-alone files, it is advisable to recompress them to\n" "If you keep any lzma-alone files, it is advisable to recompress them to\n"
@ -196,16 +196,16 @@ static void * resize_buffer( void * buf, const unsigned min_size )
} }
struct Pretty_print typedef struct Pretty_print
{ {
const char * name; const char * name;
char * padded_name; char * padded_name;
const char * stdin_name; const char * stdin_name;
unsigned longest_name; unsigned longest_name;
bool first_post; bool first_post;
}; } Pretty_print;
static void Pp_init( struct Pretty_print * const pp, static void Pp_init( Pretty_print * const pp,
const char * const filenames[], const int num_filenames ) const char * const filenames[], const int num_filenames )
{ {
pp->name = 0; pp->name = 0;
@ -226,8 +226,10 @@ static void Pp_init( struct Pretty_print * const pp,
if( pp->longest_name == 0 ) pp->longest_name = stdin_name_len; if( pp->longest_name == 0 ) pp->longest_name = stdin_name_len;
} }
static void Pp_set_name( struct Pretty_print * const pp, void Pp_free( Pretty_print * const pp )
const char * const filename ) { if( pp->padded_name ) { free( pp->padded_name ); pp->padded_name = 0; } }
static void Pp_set_name( Pretty_print * const pp, const char * const filename )
{ {
unsigned name_len, padded_name_len, i = 0; unsigned name_len, padded_name_len, i = 0;
@ -245,10 +247,10 @@ static void Pp_set_name( struct Pretty_print * const pp,
pp->first_post = true; pp->first_post = true;
} }
static void Pp_reset( struct Pretty_print * const pp ) static void Pp_reset( Pretty_print * const pp )
{ if( pp->name && pp->name[0] ) pp->first_post = true; } { if( pp->name && pp->name[0] ) pp->first_post = true; }
static void Pp_show_msg( struct Pretty_print * const pp, const char * const msg ) static void Pp_show_msg( Pretty_print * const pp, const char * const msg )
{ {
if( verbosity < 0 ) return; if( verbosity < 0 ) return;
if( pp->first_post ) if( pp->first_post )
@ -268,7 +270,7 @@ static void show_header( const unsigned dictionary_size )
const char * p = ""; const char * p = "";
const char * np = " "; const char * np = " ";
unsigned num = dictionary_size; unsigned num = dictionary_size;
bool exact = ( num % factor == 0 ); bool exact = num % factor == 0;
int i; for( i = 0; i < n && ( num > 9999 || ( exact && num >= factor ) ); ++i ) int i; for( i = 0; i < n && ( num > 9999 || ( exact && num >= factor ) ); ++i )
{ num /= factor; if( num % factor != 0 ) exact = false; { num /= factor; if( num % factor != 0 ) exact = false;
@ -289,7 +291,7 @@ static const char * format_num3( unsigned long long num )
char * const buf = buffer[current++]; current %= buffers; char * const buf = buffer[current++]; current %= buffers;
char * p = buf + bufsize - 1; /* fill the buffer backwards */ char * p = buf + bufsize - 1; /* fill the buffer backwards */
*p = 0; /* terminator */ *p = 0; /* terminator */
if( num > 1024 ) if( num > 9999 )
{ {
char prefix = 0; /* try binary first, then si */ char prefix = 0; /* try binary first, then si */
for( i = 0; i < n && num != 0 && num % 1024 == 0; ++i ) for( i = 0; i < n && num != 0 && num % 1024 == 0; ++i )
@ -385,7 +387,7 @@ static int get_dict_size( const char * const arg, const char * const option_name
} }
static void set_mode( enum Mode * const program_modep, const enum Mode new_mode ) static void set_mode( Mode * const program_modep, const Mode new_mode )
{ {
if( *program_modep != m_compress && *program_modep != new_mode ) if( *program_modep != m_compress && *program_modep != new_mode )
{ {
@ -452,13 +454,13 @@ static void set_d_outname( const char * const name, const int eindex )
static int open_instream( const char * const name, struct stat * const in_statsp, static int open_instream( const char * const name, struct stat * const in_statsp,
const enum Mode program_mode, const int eindex, const Mode program_mode, const int eindex,
const bool one_to_one, const bool recompress ) const bool one_to_one, const bool recompress )
{ {
if( program_mode == m_compress && !recompress && eindex >= 0 ) if( program_mode == m_compress && !recompress && eindex >= 0 )
{ {
if( verbosity >= 0 ) if( verbosity >= 0 )
fprintf( stderr, "%s: %s: Input file already has '%s' suffix.\n", fprintf( stderr, "%s: %s: Input file already has '%s' suffix, ignored.\n",
program_name, name, known_extensions[eindex].from ); program_name, name, known_extensions[eindex].from );
return -1; return -1;
} }
@ -469,9 +471,9 @@ static int open_instream( const char * const name, struct stat * const in_statsp
{ {
const int i = fstat( infd, in_statsp ); const int i = fstat( infd, in_statsp );
const mode_t mode = in_statsp->st_mode; const mode_t mode = in_statsp->st_mode;
const bool can_read = ( i == 0 && const bool can_read = i == 0 &&
( S_ISBLK( mode ) || S_ISCHR( mode ) || ( S_ISBLK( mode ) || S_ISCHR( mode ) ||
S_ISFIFO( mode ) || S_ISSOCK( mode ) ) ); S_ISFIFO( mode ) || S_ISSOCK( mode ) );
if( i != 0 || ( !S_ISREG( mode ) && ( !can_read || one_to_one ) ) ) if( i != 0 || ( !S_ISREG( mode ) && ( !can_read || one_to_one ) ) )
{ {
if( verbosity >= 0 ) if( verbosity >= 0 )
@ -537,7 +539,7 @@ static void signal_handler( int sig )
static bool check_tty_in( const char * const input_filename, const int infd, static bool check_tty_in( const char * const input_filename, const int infd,
const enum Mode program_mode, int * const retval ) const Mode program_mode, int * const retval )
{ {
if( ( program_mode == m_decompress || program_mode == m_test ) && if( ( program_mode == m_decompress || program_mode == m_test ) &&
isatty( infd ) ) /* for example /dev/tty */ isatty( infd ) ) /* for example /dev/tty */
@ -549,7 +551,7 @@ static bool check_tty_in( const char * const input_filename, const int infd,
return true; return true;
} }
static bool check_tty_out( const enum Mode program_mode ) static bool check_tty_out( const Mode program_mode )
{ {
if( program_mode == m_compress && isatty( outfd ) ) if( program_mode == m_compress && isatty( outfd ) )
{ show_file_error( output_filename[0] ? { show_file_error( output_filename[0] ?
@ -567,7 +569,7 @@ static void close_and_set_permissions( const struct stat * const in_statsp )
if( in_statsp ) if( in_statsp )
{ {
const mode_t mode = in_statsp->st_mode; const mode_t mode = in_statsp->st_mode;
/* fchown will in many cases return with EPERM, which can be safely ignored. */ /* fchown in many cases returns with EPERM, which can be safely ignored. */
if( fchown( outfd, in_statsp->st_uid, in_statsp->st_gid ) == 0 ) if( fchown( outfd, in_statsp->st_uid, in_statsp->st_gid ) == 0 )
{ if( fchmod( outfd, mode ) != 0 ) warning = true; } { if( fchmod( outfd, mode ) != 0 ) warning = true; }
else else
@ -593,8 +595,9 @@ static void close_and_set_permissions( const struct stat * const in_statsp )
} }
static int compress( const int infd, const struct Lzma_options * const static int compress( const int infd,
encoder_options, struct Pretty_print * const pp ) const Lzma_options * const encoder_options,
Pretty_print * const pp )
{ {
int retval = 0; int retval = 0;
CLzmaEncHandle encoder = 0; CLzmaEncHandle encoder = 0;
@ -616,7 +619,7 @@ static int compress( const int infd, const struct Lzma_options * const
} }
if( writeblock( outfd, header, Lh_size ) != Lh_size ) if( writeblock( outfd, header, Lh_size ) != Lh_size )
{ show_error( "Can't write output file", errno, false ); retval = 1; } { show_error( "Write error", errno, false ); retval = 1; }
else else
if( LzmaEnc_Encode( encoder ) != 0 ) if( LzmaEnc_Encode( encoder ) != 0 )
{ Pp_show_msg( pp, "Encoder error." ); retval = 1; } { Pp_show_msg( pp, "Encoder error." ); retval = 1; }
@ -684,7 +687,7 @@ static int lzma_decode( uint64_t unpackSize, CLzmaDec *decoder, const int infd,
unsigned long long member_size = lzma_header_size, data_size = 0; unsigned long long member_size = lzma_header_size, data_size = 0;
uint8_t outBuf[OUT_BUF_SIZE]; uint8_t outBuf[OUT_BUF_SIZE];
int outPos = 0; int outPos = 0;
const bool thereIsSize = (unpackSize != (uint64_t)-1); const bool thereIsSize = unpackSize != (uint64_t)-1;
for (;;) for (;;)
{ {
@ -711,7 +714,7 @@ static int lzma_decode( uint64_t unpackSize, CLzmaDec *decoder, const int infd,
unpackSize -= outProcessed; unpackSize -= outProcessed;
if( outfd >= 0 && writeblock( outfd, outBuf, outPos ) != outPos ) if( outfd >= 0 && writeblock( outfd, outBuf, outPos ) != outPos )
{ show_error( "Can't write output file", errno, false ); return 1; } { show_error( "Write error", errno, false ); return 1; }
data_size += outPos; data_size += outPos;
outPos = 0; outPos = 0;
@ -732,9 +735,9 @@ static int lzma_decode( uint64_t unpackSize, CLzmaDec *decoder, const int infd,
static int lzip_decode( CLzmaDec * decoder, const int infd, static int lzip_decode( CLzmaDec * decoder, const int infd,
struct Pretty_print * const pp, uint8_t inBuf[], Pretty_print * const pp, uint8_t inBuf[],
int * const inPos, int * const inSize, int * const inPos, int * const inSize,
const unsigned dictionary_size ) const unsigned dictionary_size, bool * const data0p )
{ {
unsigned long long member_size = Lh_size, data_size = 0; unsigned long long member_size = Lh_size, data_size = 0;
uint8_t outBuf[OUT_BUF_SIZE]; uint8_t outBuf[OUT_BUF_SIZE];
@ -762,7 +765,7 @@ static int lzip_decode( CLzmaDec *decoder, const int infd,
outPos += outProcessed; outPos += outProcessed;
if( outfd >= 0 && writeblock( outfd, outBuf, outPos ) != outPos ) if( outfd >= 0 && writeblock( outfd, outBuf, outPos ) != outPos )
{ show_error( "Can't write output file", errno, false ); return 1; } { show_error( "Write error", errno, false ); return 1; }
CRC32_update_buf( &crc, outBuf, outPos ); CRC32_update_buf( &crc, outBuf, outPos );
data_size += outPos; data_size += outPos;
@ -830,15 +833,16 @@ static int lzip_decode( CLzmaDec *decoder, const int infd,
} }
if( error ) return 2; if( error ) return 2;
show_results( data_size, member_size, td_crc, dictionary_size, true ); show_results( data_size, member_size, td_crc, dictionary_size, true );
*data0p = data_size == 0;
return 0; return 0;
} }
} }
} }
static int decompress( const int infd, struct Pretty_print * const pp, static int decompress( const int infd, const Cl_options * const cl_opts,
const bool ignore_trailing, const bool loose_trailing, Pretty_print * const pp,
const bool testing ) const bool from_stdin, const bool testing )
{ {
uint64_t unpackSize = 0; uint64_t unpackSize = 0;
CLzmaDec decoder; CLzmaDec decoder;
@ -848,6 +852,7 @@ static int decompress( const int infd, struct Pretty_print * const pp,
bool lzip_mode = true; bool lzip_mode = true;
bool first_member; bool first_member;
uint8_t raw_props[lzma_header_size]; uint8_t raw_props[lzma_header_size];
bool empty = false, multi = false;
for( first_member = true; ; first_member = false ) for( first_member = true; ; first_member = false )
{ {
@ -867,7 +872,7 @@ static int decompress( const int infd, struct Pretty_print * const pp,
else if( Lh_check_prefix( header, size ) ) else if( Lh_check_prefix( header, size ) )
{ Pp_show_msg( pp, "Truncated header in multimember file." ); { Pp_show_msg( pp, "Truncated header in multimember file." );
retval = 2; } retval = 2; }
else if( size > 0 && !ignore_trailing ) else if( size > 0 && !cl_opts->ignore_trailing )
{ Pp_show_msg( pp, trailing_msg ); retval = 2; } { Pp_show_msg( pp, trailing_msg ); retval = 2; }
break; break;
} }
@ -875,10 +880,10 @@ static int decompress( const int infd, struct Pretty_print * const pp,
{ {
if( !first_member ) if( !first_member )
{ {
if( !loose_trailing && Lh_check_corrupt( header ) ) if( !cl_opts->loose_trailing && Lh_check_corrupt( header ) )
{ Pp_show_msg( pp, "Corrupt header in multimember file." ); { Pp_show_msg( pp, "Corrupt header in multimember file." );
retval = 2; } retval = 2; }
else if( !ignore_trailing ) else if( !cl_opts->ignore_trailing )
{ Pp_show_msg( pp, trailing_msg ); retval = 2; } { Pp_show_msg( pp, trailing_msg ); retval = 2; }
break; break;
} }
@ -929,19 +934,23 @@ static int decompress( const int infd, struct Pretty_print * const pp,
if( !LzmaDec_Init( &decoder, raw_props ) ) if( !LzmaDec_Init( &decoder, raw_props ) )
{ Pp_show_msg( pp, mem_msg ); return 1; } { Pp_show_msg( pp, mem_msg ); return 1; }
bool data0 = false;
if( lzip_mode ) if( lzip_mode )
retval = lzip_decode( &decoder, infd, pp, inBuf, &inPos, &inSize, retval = lzip_decode( &decoder, infd, pp, inBuf, &inPos, &inSize,
dictionary_size ); dictionary_size, &data0 );
else else
retval = lzma_decode( unpackSize, &decoder, infd, inBuf, &inPos, retval = lzma_decode( unpackSize, &decoder, infd, inBuf, &inPos,
&inSize, dictionary_size, testing ); &inSize, dictionary_size, testing );
LzmaDec_Free(&decoder); LzmaDec_Free(&decoder);
if( retval != 0 || !lzip_mode ) break; if( retval != 0 || !lzip_mode ) break;
if( !from_stdin ) { multi = !first_member; if( data0 ) empty = true; }
if( verbosity >= 2 ) if( verbosity >= 2 )
{ fputs( testing ? "ok\n" : "done\n", stderr ); Pp_reset( pp ); } { fputs( testing ? "ok\n" : "done\n", stderr ); Pp_reset( pp ); }
} }
if( lzip_mode && verbosity == 1 && retval == 0 ) if( lzip_mode && verbosity == 1 && retval == 0 )
fputs( testing ? "ok\n" : "done\n", stderr ); fputs( testing ? "ok\n" : "done\n", stderr );
if( empty && multi && retval == 0 )
{ show_file_error( pp->name, empty_msg, 0 ); retval = 2; }
return retval; return retval;
} }
@ -1022,7 +1031,7 @@ int main( const int argc, const char * const argv[] )
{ {
/* Mapping from gzip/bzip2 style 0..9 compression levels to the /* Mapping from gzip/bzip2 style 0..9 compression levels to the
corresponding LZMA compression parameters. */ corresponding LZMA compression parameters. */
const struct Lzma_options option_mapping[] = const Lzma_options option_mapping[] =
{ {
{ 1 << 16, 5 }, /* -0 */ { 1 << 16, 5 }, /* -0 */
{ 1 << 20, 5 }, /* -1 */ { 1 << 20, 5 }, /* -1 */
@ -1034,20 +1043,19 @@ int main( const int argc, const char * const argv[] )
{ 1 << 24, 68 }, /* -7 */ { 1 << 24, 68 }, /* -7 */
{ 3 << 23, 132 }, /* -8 */ { 3 << 23, 132 }, /* -8 */
{ 1 << 25, 273 } }; /* -9 */ { 1 << 25, 273 } }; /* -9 */
struct Lzma_options encoder_options = option_mapping[6]; /* default = "-6" */ Lzma_options encoder_options = option_mapping[6]; /* default = "-6" */
const char * default_output_filename = ""; const char * default_output_filename = "";
enum Mode program_mode = m_compress; Mode program_mode = m_compress;
int i; Cl_options cl_opts; /* command-line options */
Cl_options_init( &cl_opts );
bool force = false; bool force = false;
bool ignore_trailing = true;
bool keep_input_files = false; bool keep_input_files = false;
bool loose_trailing = false;
bool recompress = false; bool recompress = false;
bool to_stdout = false; bool to_stdout = false;
if( argc > 0 ) invocation_name = argv[0]; if( argc > 0 ) invocation_name = argv[0];
enum { opt_lt = 256 }; enum { opt_lt = 256 };
const struct ap_Option options[] = const ap_Option options[] =
{ {
{ '0', "fast", ap_no }, { '0', "fast", ap_no },
{ '1', 0, ap_no }, { '1', 0, ap_no },
@ -1082,7 +1090,7 @@ int main( const int argc, const char * const argv[] )
CRC32_init(); CRC32_init();
/* static because valgrind complains and memory management in C sucks */ /* static because valgrind complains and memory management in C sucks */
static struct Arg_parser parser; static Arg_parser parser;
if( !ap_init( &parser, argc, argv, options, 0 ) ) if( !ap_init( &parser, argc, argv, options, 0 ) )
{ show_error( mem_msg, 0, false ); return 1; } { show_error( mem_msg, 0, false ); return 1; }
if( ap_error( &parser ) ) /* bad option */ if( ap_error( &parser ) ) /* bad option */
@ -1097,11 +1105,11 @@ int main( const int argc, const char * const argv[] )
const char * const arg = ap_argument( &parser, argind ); const char * const arg = ap_argument( &parser, argind );
switch( code ) switch( code )
{ {
case '0': case '1': case '2': case '3': case '4': case '0': case '1': case '2': case '3': case '4': case '5':
case '5': case '6': case '7': case '8': case '9': case '6': case '7': case '8': case '9':
encoder_options = option_mapping[code-'0']; break; encoder_options = option_mapping[code-'0']; break;
case 'a': ignore_trailing = false; break; case 'a': cl_opts.ignore_trailing = false; break;
case 'b': break; case 'b': break; /* ignored */
case 'c': to_stdout = true; break; case 'c': to_stdout = true; break;
case 'd': set_mode( &program_mode, m_decompress ); break; case 'd': set_mode( &program_mode, m_decompress ); break;
case 'f': force = true; break; case 'f': force = true; break;
@ -1110,17 +1118,17 @@ int main( const int argc, const char * const argv[] )
case 'k': keep_input_files = true; break; case 'k': keep_input_files = true; break;
case 'm': encoder_options.match_len_limit = case 'm': encoder_options.match_len_limit =
getnum( arg, pn, min_match_len_limit, max_match_len ); break; getnum( arg, pn, min_match_len_limit, max_match_len ); break;
case 'n': break; case 'n': break; /* ignored */
case 'o': if( strcmp( arg, "-" ) == 0 ) to_stdout = true; case 'o': if( strcmp( arg, "-" ) == 0 ) to_stdout = true;
else { default_output_filename = arg; } break; else { default_output_filename = arg; } break;
case 'q': verbosity = -1; break; case 'q': verbosity = -1; break;
case 's': encoder_options.dictionary_size = get_dict_size( arg, pn ); case 's': encoder_options.dictionary_size = get_dict_size( arg, pn );
break; break;
case 'S': break; case 'S': break; /* ignored */
case 't': set_mode( &program_mode, m_test ); break; case 't': set_mode( &program_mode, m_test ); break;
case 'v': if( verbosity < 4 ) ++verbosity; break; case 'v': if( verbosity < 4 ) ++verbosity; break;
case 'V': show_version(); return 0; case 'V': show_version(); return 0;
case opt_lt: loose_trailing = true; break; case opt_lt: cl_opts.loose_trailing = true; break;
default: internal_error( "uncaught option." ); default: internal_error( "uncaught option." );
} }
} /* end process options */ } /* end process options */
@ -1135,6 +1143,7 @@ int main( const int argc, const char * const argv[] )
filenames = resize_buffer( filenames, num_filenames * sizeof filenames[0] ); filenames = resize_buffer( filenames, num_filenames * sizeof filenames[0] );
filenames[0] = "-"; filenames[0] = "-";
int i;
bool filenames_given = false; bool filenames_given = false;
for( i = 0; argind + i < ap_arguments( &parser ); ++i ) for( i = 0; argind + i < ap_arguments( &parser ); ++i )
{ {
@ -1156,21 +1165,22 @@ int main( const int argc, const char * const argv[] )
if( !to_stdout && program_mode != m_test && ( filenames_given || to_file ) ) if( !to_stdout && program_mode != m_test && ( filenames_given || to_file ) )
set_signals( signal_handler ); set_signals( signal_handler );
static struct Pretty_print pp; static Pretty_print pp;
Pp_init( &pp, filenames, num_filenames ); Pp_init( &pp, filenames, num_filenames );
int failed_tests = 0; int failed_tests = 0;
int retval = 0; int retval = 0;
const bool one_to_one = !to_stdout && program_mode != m_test && !to_file; const bool one_to_one = !to_stdout && program_mode != m_test && !to_file;
bool stdin_used = false; bool stdin_used = false;
struct stat in_stats;
for( i = 0; i < num_filenames; ++i ) for( i = 0; i < num_filenames; ++i )
{ {
const char * input_filename = ""; const char * input_filename = "";
int infd; int infd;
struct stat in_stats; const bool from_stdin = strcmp( filenames[i], "-" ) == 0;
Pp_set_name( &pp, filenames[i] ); Pp_set_name( &pp, filenames[i] );
if( strcmp( filenames[i], "-" ) == 0 ) if( from_stdin )
{ {
if( stdin_used ) continue; else stdin_used = true; if( stdin_used ) continue; else stdin_used = true;
infd = STDIN_FILENO; infd = STDIN_FILENO;
@ -1215,7 +1225,7 @@ int main( const int argc, const char * const argv[] )
if( program_mode == m_compress ) if( program_mode == m_compress )
tmp = compress( infd, &encoder_options, &pp ); tmp = compress( infd, &encoder_options, &pp );
else else
tmp = decompress( infd, &pp, ignore_trailing, loose_trailing, tmp = decompress( infd, &cl_opts, &pp, from_stdin,
program_mode == m_test ); program_mode == m_test );
if( close( infd ) != 0 ) if( close( infd ) != 0 )
{ show_file_error( pp.name, "Error closing input file", errno ); { show_file_error( pp.name, "Error closing input file", errno );
@ -1230,7 +1240,9 @@ int main( const int argc, const char * const argv[] )
if( input_filename[0] && !keep_input_files && one_to_one ) if( input_filename[0] && !keep_input_files && one_to_one )
remove( input_filename ); remove( input_filename );
} }
if( delete_output_on_interrupt ) close_and_set_permissions( 0 ); /* -o */ if( delete_output_on_interrupt ) /* -o */
close_and_set_permissions( ( retval == 0 && !stdin_used &&
filenames_given && num_filenames == 1 ) ? &in_stats : 0 );
else if( outfd >= 0 && close( outfd ) != 0 ) /* -c */ else if( outfd >= 0 && close( outfd ) != 0 ) /* -c */
{ {
show_error( "Error closing stdout", errno, false ); show_error( "Error closing stdout", errno, false );
@ -1241,6 +1253,7 @@ int main( const int argc, const char * const argv[] )
program_name, failed_tests, program_name, failed_tests,
( failed_tests == 1 ) ? "file" : "files" ); ( failed_tests == 1 ) ? "file" : "files" );
free( output_filename ); free( output_filename );
Pp_free( &pp );
free( filenames ); free( filenames );
ap_free( &parser ); ap_free( &parser );
return retval; return retval;

View file

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# check script for Pdlzip - LZMA lossless data compressor # check script for Pdlzip - LZMA lossless data compressor
# Copyright (C) 2010-2023 Antonio Diaz Diaz. # Copyright (C) 2010-2025 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.
@ -28,10 +28,10 @@ if [ -d tmp ] ; then rm -rf tmp ; fi
mkdir tmp mkdir tmp
cd "${objdir}"/tmp || framework_failure cd "${objdir}"/tmp || framework_failure
cat "${testdir}"/test.txt > in || framework_failure cp "${testdir}"/test.txt in || framework_failure
in_lz="${testdir}"/test.txt.lz in_lz="${testdir}"/test.txt.lz
in_em="${testdir}"/test_em.txt.lz
fox_lz="${testdir}"/fox.lz fox_lz="${testdir}"/fox.lz
fnz_lz="${testdir}"/fox_nz.lz
fail=0 fail=0
test_failed() { fail=1 ; printf " $1" ; [ -z "$2" ] || printf "($2)" ; } test_failed() { fail=1 ; printf " $1" ; [ -z "$2" ] || printf "($2)" ; }
@ -95,7 +95,7 @@ printf "LZIP\001+.............................." | "${LZIP}" -t 2> /dev/null
printf "\ntesting decompression..." printf "\ntesting decompression..."
for i in "${in_lz}" "${in_em}" "${testdir}"/test.txt.lzma ; do for i in "${in_lz}" "${testdir}"/test.txt.lzma ; do
"${LZIP}" -t "$i" || test_failed $LINENO "$i" "${LZIP}" -t "$i" || test_failed $LINENO "$i"
"${LZIP}" -d "$i" -o out || test_failed $LINENO "$i" "${LZIP}" -d "$i" -o out || test_failed $LINENO "$i"
cmp in out || test_failed $LINENO "$i" cmp in out || test_failed $LINENO "$i"
@ -108,16 +108,13 @@ for i in "${in_lz}" "${in_em}" "${testdir}"/test.txt.lzma ; do
rm -f out || framework_failure rm -f out || framework_failure
done done
lines=`"${LZIP}" -tvv "${in_em}" 2>&1 | wc -l` || test_failed $LINENO cp "${in_lz}" out.lz || framework_failure
[ "${lines}" -eq 8 ] || test_failed $LINENO "${lines}"
cat "${in_lz}" > out.lz || framework_failure
"${LZIP}" -dk out.lz || test_failed $LINENO "${LZIP}" -dk out.lz || test_failed $LINENO
cmp in out || test_failed $LINENO cmp in out || test_failed $LINENO
rm -f out || framework_failure rm -f out || framework_failure
"${LZIP}" -cd "${fox_lz}" > fox || test_failed $LINENO "${LZIP}" -cd "${fox_lz}" > fox || test_failed $LINENO
cat fox > copy || framework_failure cp fox copy || framework_failure
cat "${in_lz}" > copy.lz || framework_failure cp "${in_lz}" copy.lz || framework_failure
"${LZIP}" -d copy.lz out.lz 2> /dev/null # skip copy, decompress out "${LZIP}" -d copy.lz out.lz 2> /dev/null # skip copy, decompress out
[ $? = 1 ] || test_failed $LINENO [ $? = 1 ] || test_failed $LINENO
[ ! -e out.lz ] || test_failed $LINENO [ ! -e out.lz ] || test_failed $LINENO
@ -131,7 +128,6 @@ rm -f copy out || framework_failure
printf "to be overwritten" > out || framework_failure printf "to be overwritten" > out || framework_failure
"${LZIP}" -df -o out < "${in_lz}" || test_failed $LINENO "${LZIP}" -df -o out < "${in_lz}" || test_failed $LINENO
cmp in out || test_failed $LINENO cmp in out || test_failed $LINENO
rm -f out || framework_failure
"${LZIP}" -d -o ./- "${in_lz}" || test_failed $LINENO "${LZIP}" -d -o ./- "${in_lz}" || test_failed $LINENO
cmp in ./- || test_failed $LINENO cmp in ./- || test_failed $LINENO
rm -f ./- || framework_failure rm -f ./- || framework_failure
@ -139,12 +135,12 @@ rm -f ./- || framework_failure
cmp in ./- || test_failed $LINENO cmp in ./- || test_failed $LINENO
rm -f ./- || framework_failure rm -f ./- || framework_failure
cat "${in_lz}" > anyothername || framework_failure cp "${in_lz}" anyothername || framework_failure
"${LZIP}" -dv - anyothername - < "${in_lz}" > out 2> /dev/null || "${LZIP}" -dv - anyothername - < "${in_lz}" > out 2> /dev/null ||
test_failed $LINENO test_failed $LINENO
cmp in out || test_failed $LINENO cmp in out || test_failed $LINENO
cmp in anyothername.out || test_failed $LINENO cmp in anyothername.out || test_failed $LINENO
rm -f out anyothername.out || framework_failure rm -f anyothername.out || framework_failure
"${LZIP}" -tq in "${in_lz}" "${LZIP}" -tq in "${in_lz}"
[ $? = 2 ] || test_failed $LINENO [ $? = 2 ] || test_failed $LINENO
@ -157,7 +153,7 @@ cat out in | cmp in - || test_failed $LINENO # out must be empty
[ $? = 1 ] || test_failed $LINENO [ $? = 1 ] || test_failed $LINENO
cmp in out || test_failed $LINENO cmp in out || test_failed $LINENO
rm -f out || framework_failure rm -f out || framework_failure
cat "${in_lz}" > out.lz || framework_failure cp "${in_lz}" out.lz || framework_failure
for i in 1 2 3 4 5 6 7 ; do for i in 1 2 3 4 5 6 7 ; do
printf "g" >> out.lz || framework_failure printf "g" >> out.lz || framework_failure
"${LZIP}" -atvvvv out.lz "${in_lz}" 2> /dev/null "${LZIP}" -atvvvv out.lz "${in_lz}" 2> /dev/null
@ -186,6 +182,9 @@ cmp in2 out2 || test_failed $LINENO
rm -f out2 || framework_failure rm -f out2 || framework_failure
cat "${in_lz}" "${in_lz}" > out2.lz || framework_failure cat "${in_lz}" "${in_lz}" > out2.lz || framework_failure
lines=`"${LZIP}" -tvv out2.lz 2>&1 | wc -l` || test_failed $LINENO
[ "${lines}" -eq 2 ] || test_failed $LINENO "${lines}"
printf "\ngarbage" >> out2.lz || framework_failure printf "\ngarbage" >> out2.lz || framework_failure
"${LZIP}" -tvvvv out2.lz 2> /dev/null || test_failed $LINENO "${LZIP}" -tvvvv out2.lz 2> /dev/null || test_failed $LINENO
"${LZIP}" -atq out2.lz "${LZIP}" -atq out2.lz
@ -203,6 +202,20 @@ printf "to be overwritten" > out2 || framework_failure
cmp in2 out2 || test_failed $LINENO cmp in2 out2 || test_failed $LINENO
rm -f out2 || framework_failure rm -f out2 || framework_failure
touch empty em || framework_failure
"${LZIP}" -0 em || test_failed $LINENO
"${LZIP}" -dk em.lz || test_failed $LINENO
cmp empty em || test_failed $LINENO
cat em.lz em.lz | "${LZIP}" -t || test_failed $LINENO
cat em.lz em.lz | "${LZIP}" -d > em || test_failed $LINENO
cmp empty em || test_failed $LINENO
cat em.lz "${in_lz}" | "${LZIP}" -t || test_failed $LINENO
cat em.lz "${in_lz}" | "${LZIP}" -d > out || test_failed $LINENO
cmp in out || test_failed $LINENO
cat "${in_lz}" em.lz | "${LZIP}" -t || test_failed $LINENO
cat "${in_lz}" em.lz | "${LZIP}" -d > out || test_failed $LINENO
cmp in out || test_failed $LINENO
printf "\ntesting compression..." printf "\ntesting compression..."
"${LZIP}" -c -0 in in in -o out3.lz > copy2.lz || test_failed $LINENO "${LZIP}" -c -0 in in in -o out3.lz > copy2.lz || test_failed $LINENO
@ -211,7 +224,7 @@ printf "\ntesting compression..."
"${LZIP}" -d copy2.lz -o out2 || test_failed $LINENO "${LZIP}" -d copy2.lz -o out2 || test_failed $LINENO
[ -e copy2.lz ] || test_failed $LINENO [ -e copy2.lz ] || test_failed $LINENO
cmp in2 out2 || test_failed $LINENO cmp in2 out2 || test_failed $LINENO
rm -f in2 out2 copy2.lz || framework_failure rm -f copy2.lz || framework_failure
"${LZIP}" -cf "${in_lz}" > lzlz 2> /dev/null # /dev/null is a tty on OS/2 "${LZIP}" -cf "${in_lz}" > lzlz 2> /dev/null # /dev/null is a tty on OS/2
[ $? = 1 ] || test_failed $LINENO [ $? = 1 ] || test_failed $LINENO
@ -259,11 +272,38 @@ rm -f copy out.lz || framework_failure
printf "\ntesting bad input..." printf "\ntesting bad input..."
cat em.lz em.lz > ee.lz || framework_failure
"${LZIP}" -t < ee.lz || test_failed $LINENO
"${LZIP}" -d < ee.lz > em || test_failed $LINENO
cmp empty em || test_failed $LINENO
"${LZIP}" -tq ee.lz
[ $? = 2 ] || test_failed $LINENO
"${LZIP}" -dq ee.lz
[ $? = 2 ] || test_failed $LINENO
[ ! -e ee ] || test_failed $LINENO
"${LZIP}" -cdq ee.lz > em
[ $? = 2 ] || test_failed $LINENO
cmp empty em || test_failed $LINENO
rm -f empty em || framework_failure
cat "${in_lz}" em.lz "${in_lz}" > inein.lz || framework_failure
"${LZIP}" -t < inein.lz || test_failed $LINENO
"${LZIP}" -d < inein.lz > out2 || test_failed $LINENO
cmp in2 out2 || test_failed $LINENO
"${LZIP}" -tq inein.lz
[ $? = 2 ] || test_failed $LINENO
"${LZIP}" -dq inein.lz
[ $? = 2 ] || test_failed $LINENO
[ ! -e inein ] || test_failed $LINENO
"${LZIP}" -cdq inein.lz > out2
[ $? = 2 ] || test_failed $LINENO
cmp in2 out2 || test_failed $LINENO
rm -f in2 out2 inein.lz em.lz || framework_failure
headers='LZIp LZiP LZip LzIP LzIp LziP lZIP lZIp lZiP lzIP' headers='LZIp LZiP LZip LzIP LzIp LziP lZIP lZIp lZiP lzIP'
body='\001\014\000\203\377\373\377\377\300\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000$\000\000\000\000\000\000\000' body='\001\014\000\000\101\376\367\377\377\340\000\200\000\215\357\002\322\001\000\000\000\000\000\000\000\045\000\000\000\000\000\000\000'
cat "${in_lz}" > int.lz || framework_failure cp "${in_lz}" int.lz || framework_failure
printf "LZIP${body}" >> int.lz || framework_failure printf "LZIP${body}" >> int.lz || framework_failure
if "${LZIP}" -tq int.lz ; then if "${LZIP}" -t int.lz ; then
for header in ${headers} ; do for header in ${headers} ; do
printf "${header}${body}" > int.lz || framework_failure printf "${header}${body}" > int.lz || framework_failure
"${LZIP}" -tq int.lz # first member "${LZIP}" -tq int.lz # first member
@ -278,7 +318,7 @@ if "${LZIP}" -tq int.lz ; then
[ $? = 2 ] || test_failed $LINENO ${header} [ $? = 2 ] || test_failed $LINENO ${header}
"${LZIP}" -cdq --loose-trailing int.lz > /dev/null "${LZIP}" -cdq --loose-trailing int.lz > /dev/null
[ $? = 2 ] || test_failed $LINENO ${header} [ $? = 2 ] || test_failed $LINENO ${header}
cat "${in_lz}" > int.lz || framework_failure cp "${in_lz}" int.lz || framework_failure
printf "${header}${body}" >> int.lz || framework_failure printf "${header}${body}" >> int.lz || framework_failure
"${LZIP}" -tq int.lz # trailing data "${LZIP}" -tq int.lz # trailing data
[ $? = 2 ] || test_failed $LINENO ${header} [ $? = 2 ] || test_failed $LINENO ${header}
@ -300,10 +340,13 @@ if "${LZIP}" -tq int.lz ; then
[ $? = 2 ] || test_failed $LINENO ${header} [ $? = 2 ] || test_failed $LINENO ${header}
done done
else else
printf "\nwarning: skipping header test: 'printf' does not work on your system." printf "warning: skipping header test: 'printf' does not work on your system."
fi fi
rm -f int.lz || framework_failure rm -f int.lz || framework_failure
"${LZIP}" -tq "${fnz_lz}"
[ $? = 2 ] || test_failed $LINENO
for i in fox_v2.lz fox_s11.lz fox_de20.lz \ for i in fox_v2.lz fox_s11.lz fox_de20.lz \
fox_bcrc.lz fox_crc0.lz fox_das46.lz fox_mes81.lz ; do fox_bcrc.lz fox_crc0.lz fox_das46.lz fox_mes81.lz ; do
"${LZIP}" -tq "${testdir}"/$i "${LZIP}" -tq "${testdir}"/$i
@ -315,13 +358,13 @@ for i in fox_bcrc.lz fox_crc0.lz fox_das46.lz fox_mes81.lz ; do
[ $? = 2 ] || test_failed $LINENO $i [ $? = 2 ] || test_failed $LINENO $i
cmp fox out || test_failed $LINENO $i cmp fox out || test_failed $LINENO $i
done done
rm -f fox out || framework_failure rm -f fox || framework_failure
cat "${in_lz}" "${in_lz}" > in2.lz || framework_failure cat "${in_lz}" "${in_lz}" > in2.lz || framework_failure
cat "${in_lz}" "${in_lz}" "${in_lz}" > in3.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 && if dd if=in3.lz of=trunc.lz bs=14682 count=1 2> /dev/null &&
[ -e trunc.lz ] && cmp in2.lz trunc.lz > /dev/null 2>&1 ; then [ -e trunc.lz ] && cmp in2.lz trunc.lz ; then
for i in 6 20 14734 14753 14754 14755 14756 14757 14758 ; do for i in 6 20 14664 14683 14684 14685 14686 14687 14688 ; do
dd if=in3.lz of=trunc.lz bs=$i count=1 2> /dev/null dd if=in3.lz of=trunc.lz bs=$i count=1 2> /dev/null
"${LZIP}" -tq trunc.lz "${LZIP}" -tq trunc.lz
[ $? = 2 ] || test_failed $LINENO $i [ $? = 2 ] || test_failed $LINENO $i
@ -333,28 +376,32 @@ if dd if=in3.lz of=trunc.lz bs=14752 count=1 2> /dev/null &&
[ $? = 2 ] || test_failed $LINENO $i [ $? = 2 ] || test_failed $LINENO $i
done done
else else
printf "\nwarning: skipping truncation test: 'dd' does not work on your system." printf "warning: skipping truncation test: 'dd' does not work on your system."
fi fi
rm -f in2.lz in3.lz trunc.lz || framework_failure rm -f in2.lz in3.lz trunc.lz || framework_failure
cat "${in_lz}" > ingin.lz || framework_failure cp "${in_lz}" ingin.lz || framework_failure
printf "g" >> ingin.lz || framework_failure printf "g" >> ingin.lz || framework_failure
cat "${in_lz}" >> ingin.lz || framework_failure cat "${in_lz}" >> ingin.lz || framework_failure
"${LZIP}" -atq ingin.lz "${LZIP}" -atq ingin.lz
[ $? = 2 ] || test_failed $LINENO [ $? = 2 ] || test_failed $LINENO
"${LZIP}" -atq < ingin.lz "${LZIP}" -atq < ingin.lz
[ $? = 2 ] || test_failed $LINENO [ $? = 2 ] || test_failed $LINENO
"${LZIP}" -acdq ingin.lz > /dev/null "${LZIP}" -acdq ingin.lz > out
[ $? = 2 ] || test_failed $LINENO [ $? = 2 ] || test_failed $LINENO
"${LZIP}" -adq < ingin.lz > /dev/null cmp in out || test_failed $LINENO
"${LZIP}" -adq < ingin.lz > out
[ $? = 2 ] || test_failed $LINENO [ $? = 2 ] || test_failed $LINENO
cmp in out || test_failed $LINENO
"${LZIP}" -t ingin.lz || test_failed $LINENO "${LZIP}" -t ingin.lz || test_failed $LINENO
"${LZIP}" -t < ingin.lz || test_failed $LINENO "${LZIP}" -t < ingin.lz || test_failed $LINENO
"${LZIP}" -dk ingin.lz || test_failed $LINENO
cmp in ingin || test_failed $LINENO
"${LZIP}" -cd ingin.lz > out || test_failed $LINENO "${LZIP}" -cd ingin.lz > out || test_failed $LINENO
cmp in out || test_failed $LINENO cmp in out || test_failed $LINENO
"${LZIP}" -d < ingin.lz > out || test_failed $LINENO "${LZIP}" -d < ingin.lz > out || test_failed $LINENO
cmp in out || test_failed $LINENO cmp in out || test_failed $LINENO
rm -f out ingin.lz || framework_failure rm -f out ingin ingin.lz || framework_failure
echo echo
if [ ${fail} = 0 ] ; then if [ ${fail} = 0 ] ; then

BIN
testsuite/fox_nz.lz Normal file

Binary file not shown.

View file

@ -1,8 +1,7 @@
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 2, June 1991 Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., Copyright (C) 1989, 1991 Free Software Foundation, Inc. <http://fsf.org/>
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.
@ -339,8 +338,7 @@ Public License instead of this License.
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 2, June 1991 Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., Copyright (C) 1989, 1991 Free Software Foundation, Inc. <http://fsf.org/>
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.

Binary file not shown.

Binary file not shown.

Binary file not shown.