Adding upstream version 1.8.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
29d0941b98
commit
8fbfbdc103
13 changed files with 269 additions and 183 deletions
19
COPYING
Normal file
19
COPYING
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
Pdlzip - LZMA lossless data compressor
|
||||||
|
Copyright (C) Antonio Diaz Diaz.
|
||||||
|
Pdlzip includes public domain (de)compression code from the LZMA SDK
|
||||||
|
(Software Development Kit) written by Igor Pavlov.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
|
@ -1,3 +1,9 @@
|
||||||
|
2017-04-12 Antonio Diaz Diaz <antonio@gnu.org>
|
||||||
|
|
||||||
|
* Version 1.8 released.
|
||||||
|
* main.c: Continue testing if any input file is a terminal.
|
||||||
|
* main.c (decompress): Improved detection of trailing data.
|
||||||
|
|
||||||
2016-05-16 Antonio Diaz Diaz <antonio@gnu.org>
|
2016-05-16 Antonio Diaz Diaz <antonio@gnu.org>
|
||||||
|
|
||||||
* Version 1.7 released.
|
* Version 1.7 released.
|
||||||
|
@ -67,7 +73,7 @@
|
||||||
* Using LZMA SDK 9.10 (public domain) from Igor Pavlov.
|
* Using LZMA SDK 9.10 (public domain) from Igor Pavlov.
|
||||||
|
|
||||||
|
|
||||||
Copyright (C) 2010-2016 Antonio Diaz Diaz.
|
Copyright (C) 2010-2017 Antonio Diaz Diaz.
|
||||||
|
|
||||||
This file is a collection of facts, and thus it is not copyrightable,
|
This file is a collection of facts, and thus it is not copyrightable,
|
||||||
but just in case, you have unlimited permission to copy, distribute and
|
but just in case, you have unlimited permission to copy, distribute and
|
||||||
|
|
2
INSTALL
2
INSTALL
|
@ -61,7 +61,7 @@ After running 'configure', you can run 'make' and 'make install' as
|
||||||
explained above.
|
explained above.
|
||||||
|
|
||||||
|
|
||||||
Copyright (C) 2010-2016 Antonio Diaz Diaz.
|
Copyright (C) 2010-2017 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.
|
||||||
|
|
10
Makefile.in
10
Makefile.in
|
@ -13,7 +13,8 @@ objs = carg_parser.o LzFind.o LzmaEnc.o LzmaDec.o main.o
|
||||||
.PHONY : all install install-bin install-info install-man \
|
.PHONY : all install install-bin install-info install-man \
|
||||||
install-strip install-compress install-strip-compress \
|
install-strip install-compress install-strip-compress \
|
||||||
install-bin-strip install-info-compress install-man-compress \
|
install-bin-strip install-info-compress install-man-compress \
|
||||||
install-as-lzip uninstall uninstall-bin uninstall-info uninstall-man \
|
install-as-lzip \
|
||||||
|
uninstall uninstall-bin uninstall-info uninstall-man \
|
||||||
doc info man check dist clean distclean
|
doc info man check dist clean distclean
|
||||||
|
|
||||||
all : $(progname)
|
all : $(progname)
|
||||||
|
@ -106,6 +107,7 @@ dist : doc
|
||||||
ln -sf $(VPATH) $(DISTNAME)
|
ln -sf $(VPATH) $(DISTNAME)
|
||||||
tar -Hustar --owner=root --group=root -cvf $(DISTNAME).tar \
|
tar -Hustar --owner=root --group=root -cvf $(DISTNAME).tar \
|
||||||
$(DISTNAME)/AUTHORS \
|
$(DISTNAME)/AUTHORS \
|
||||||
|
$(DISTNAME)/COPYING \
|
||||||
$(DISTNAME)/ChangeLog \
|
$(DISTNAME)/ChangeLog \
|
||||||
$(DISTNAME)/INSTALL \
|
$(DISTNAME)/INSTALL \
|
||||||
$(DISTNAME)/Makefile.in \
|
$(DISTNAME)/Makefile.in \
|
||||||
|
@ -113,12 +115,12 @@ dist : doc
|
||||||
$(DISTNAME)/README \
|
$(DISTNAME)/README \
|
||||||
$(DISTNAME)/configure \
|
$(DISTNAME)/configure \
|
||||||
$(DISTNAME)/doc/$(progname).1 \
|
$(DISTNAME)/doc/$(progname).1 \
|
||||||
|
$(DISTNAME)/*.h \
|
||||||
|
$(DISTNAME)/*.c \
|
||||||
$(DISTNAME)/testsuite/check.sh \
|
$(DISTNAME)/testsuite/check.sh \
|
||||||
$(DISTNAME)/testsuite/test.txt \
|
$(DISTNAME)/testsuite/test.txt \
|
||||||
$(DISTNAME)/testsuite/test.txt.lz \
|
$(DISTNAME)/testsuite/test.txt.lz \
|
||||||
$(DISTNAME)/testsuite/test.txt.lzma \
|
$(DISTNAME)/testsuite/test.txt.lzma
|
||||||
$(DISTNAME)/*.h \
|
|
||||||
$(DISTNAME)/*.c
|
|
||||||
rm -f $(DISTNAME)
|
rm -f $(DISTNAME)
|
||||||
lzip -v -9 $(DISTNAME).tar
|
lzip -v -9 $(DISTNAME).tar
|
||||||
|
|
||||||
|
|
13
NEWS
13
NEWS
|
@ -1,11 +1,6 @@
|
||||||
Changes in version 1.7:
|
Changes in version 1.8:
|
||||||
|
|
||||||
The option "-a, --trailing-error", which makes pdlzip exit with error
|
In test mode, pdlzip now continues checking the rest of the files if any
|
||||||
status 2 if any remaining input is detected after decompressing the last
|
input file is a terminal.
|
||||||
member, has been added.
|
|
||||||
|
|
||||||
When decompressing, the file specified with the '--output' option is now
|
Trailing data shorter than a lzip header are now also reported.
|
||||||
deleted if the input is a terminal.
|
|
||||||
|
|
||||||
A harmless check failure on Windows, caused by the failed comparison of
|
|
||||||
a message in text mode, has been fixed.
|
|
||||||
|
|
14
README
14
README
|
@ -20,11 +20,11 @@ availability:
|
||||||
merging of damaged copies of a file.
|
merging of damaged copies of a file.
|
||||||
|
|
||||||
* The lzip format is as simple as possible (but not simpler). The
|
* The lzip format is as simple as possible (but not simpler). The
|
||||||
lzip manual provides the code of a simple decompressor along with a
|
lzip manual provides the source code of a simple decompressor along
|
||||||
detailed explanation of how it works, so that with the only help of
|
with a detailed explanation of how it works, so that with the only
|
||||||
the lzip manual it would be possible for a digital archaeologist to
|
help of the lzip manual it would be possible for a digital
|
||||||
extract the data from a lzip file long after quantum computers
|
archaeologist to extract the data from a lzip file long after
|
||||||
eventually render LZMA obsolete.
|
quantum computers eventually render LZMA obsolete.
|
||||||
|
|
||||||
* Additionally the lzip reference implementation is copylefted, which
|
* Additionally the lzip reference implementation is copylefted, which
|
||||||
guarantees that it will remain free forever.
|
guarantees that it will remain free forever.
|
||||||
|
@ -37,7 +37,7 @@ corrupt byte near the beginning is a thing of the past.
|
||||||
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.
|
||||||
If you keep any lzma-alone files, it is advisable to recompress them to
|
If you keep any lzma-alone files, it is advisable to recompress them to
|
||||||
lzip format. Lziprecover can convert lzma-alone files to lzip format
|
lzip format. Lziprecover can convert some lzma-alone files to lzip format
|
||||||
without recompressing.
|
without recompressing.
|
||||||
|
|
||||||
Pdlzip is written in C.
|
Pdlzip is written in C.
|
||||||
|
@ -52,7 +52,7 @@ users of the most non-free platforms can share lzip files with everybody
|
||||||
else.
|
else.
|
||||||
|
|
||||||
|
|
||||||
Copyright (C) 2010-2016 Antonio Diaz Diaz.
|
Copyright (C) 2010-2017 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.
|
||||||
|
|
|
@ -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-2016 Antonio Diaz Diaz.
|
Copyright (C) 2006-2017 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
|
||||||
|
@ -94,7 +94,7 @@ static char parse_long_option( struct Arg_parser * const ap,
|
||||||
else if( index < 0 ) index = i; /* First nonexact match found */
|
else if( index < 0 ) index = i; /* First nonexact match found */
|
||||||
else if( options[index].code != options[i].code ||
|
else if( options[index].code != options[i].code ||
|
||||||
options[index].has_arg != options[i].has_arg )
|
options[index].has_arg != options[i].has_arg )
|
||||||
ambig = 1; /* Second or later nonexact match found */
|
ambig = 1; /* Second or later nonexact match found */
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ambig && !exact )
|
if( ambig && !exact )
|
||||||
|
@ -230,7 +230,9 @@ char ap_init( struct Arg_parser * const ap,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( !in_order )
|
if( in_order )
|
||||||
|
{ if( !push_back_record( ap, 0, argv[argind++] ) ) return 0; }
|
||||||
|
else
|
||||||
{
|
{
|
||||||
void * tmp = ap_resize_buffer( non_options,
|
void * tmp = ap_resize_buffer( non_options,
|
||||||
( non_options_size + 1 ) * sizeof *non_options );
|
( non_options_size + 1 ) * sizeof *non_options );
|
||||||
|
@ -238,7 +240,6 @@ char ap_init( struct Arg_parser * const ap,
|
||||||
non_options = (const char **)tmp;
|
non_options = (const char **)tmp;
|
||||||
non_options[non_options_size++] = argv[argind++];
|
non_options[non_options_size++] = argv[argind++];
|
||||||
}
|
}
|
||||||
else if( !push_back_record( ap, 0, argv[argind++] ) ) return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( ap->error ) free_data( ap );
|
if( ap->error ) free_data( ap );
|
||||||
|
|
|
@ -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-2016 Antonio Diaz Diaz.
|
Copyright (C) 2006-2017 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
|
||||||
|
|
21
configure
vendored
21
configure
vendored
|
@ -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-2016 Antonio Diaz Diaz.
|
# Copyright (C) 2010-2017 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.7
|
pkgversion=1.8
|
||||||
progname=pdlzip
|
progname=pdlzip
|
||||||
srctrigger=doc/${progname}.1
|
srctrigger=doc/${progname}.1
|
||||||
|
|
||||||
|
@ -26,11 +26,11 @@ CFLAGS='-Wall -W -O2'
|
||||||
LDFLAGS=
|
LDFLAGS=
|
||||||
|
|
||||||
# checking whether we are using GNU C.
|
# checking whether we are using GNU C.
|
||||||
if /bin/sh -c "${CC} --version" > /dev/null 2>&1 ; then true
|
/bin/sh -c "${CC} --version" > /dev/null 2>&1 ||
|
||||||
else
|
{
|
||||||
CC=cc
|
CC=cc
|
||||||
CFLAGS='-W -O2'
|
CFLAGS=-O2
|
||||||
fi
|
}
|
||||||
|
|
||||||
# Loop over all args
|
# Loop over all args
|
||||||
args=
|
args=
|
||||||
|
@ -52,9 +52,12 @@ while [ $# != 0 ] ; do
|
||||||
# Process the options
|
# Process the options
|
||||||
case ${option} in
|
case ${option} in
|
||||||
--help | -h)
|
--help | -h)
|
||||||
echo "Usage: configure [options]"
|
echo "Usage: $0 [OPTION]... [VAR=VALUE]..."
|
||||||
echo
|
echo
|
||||||
echo "Options: [defaults in brackets]"
|
echo "To assign makefile variables (e.g., CC, CFLAGS...), specify them as"
|
||||||
|
echo "arguments to configure in the form VAR=VALUE."
|
||||||
|
echo
|
||||||
|
echo "Options and variables: [defaults in brackets]"
|
||||||
echo " -h, --help display this help and exit"
|
echo " -h, --help display this help and exit"
|
||||||
echo " -V, --version output version information and exit"
|
echo " -V, --version output version information and exit"
|
||||||
echo " --srcdir=DIR find the sources in DIR [. or ..]"
|
echo " --srcdir=DIR find the sources in DIR [. or ..]"
|
||||||
|
@ -165,7 +168,7 @@ echo "LDFLAGS = ${LDFLAGS}"
|
||||||
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-2016 Antonio Diaz Diaz.
|
# Copyright (C) 2010-2017 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
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.46.1.
|
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.46.1.
|
||||||
.TH PDLZIP "1" "May 2016" "pdlzip 1.7" "User Commands"
|
.TH PDLZIP "1" "April 2017" "pdlzip 1.8" "User Commands"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
pdlzip \- reduces the size of files
|
pdlzip \- reduces the size of files
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
@ -11,7 +11,7 @@ compressor also able to decompress legacy lzma\-alone (.lzma) files.
|
||||||
.PP
|
.PP
|
||||||
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.
|
||||||
If you keep any lzma\-alone files, it is advisable to recompress them to
|
If you keep any lzma\-alone files, it is advisable to recompress them to
|
||||||
lzip format. Lziprecover can convert lzma\-alone files to lzip format
|
lzip format. Lziprecover can convert some lzma\-alone files to lzip format
|
||||||
without recompressing.
|
without recompressing.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
|
@ -88,7 +88,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 2016 Antonio Diaz Diaz.
|
Copyright \(co 2017 Antonio Diaz Diaz.
|
||||||
Public Domain 2009 Igor Pavlov.
|
Public Domain 2009 Igor Pavlov.
|
||||||
License 2\-clause BSD.
|
License 2\-clause BSD.
|
||||||
.br
|
.br
|
||||||
|
|
18
lzip.h
18
lzip.h
|
@ -1,5 +1,5 @@
|
||||||
/* Pdlzip - LZMA lossless data compressor
|
/* Pdlzip - LZMA lossless data compressor
|
||||||
Copyright (C) 2010-2016 Antonio Diaz Diaz.
|
Copyright (C) 2010-2017 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
|
||||||
|
@ -29,8 +29,10 @@ typedef int State;
|
||||||
enum {
|
enum {
|
||||||
min_dictionary_bits = 12,
|
min_dictionary_bits = 12,
|
||||||
min_dictionary_size = 1 << min_dictionary_bits,
|
min_dictionary_size = 1 << min_dictionary_bits,
|
||||||
max_dictionary_bits = 27, /* kDicLogSizeMaxCompress */
|
max_dictionary_bits = 29,
|
||||||
max_dictionary_size = 1 << max_dictionary_bits,
|
max_dictionary_size = 1 << max_dictionary_bits,
|
||||||
|
max_dictionary_bits_c = 27, /* kDicLogSizeMaxCompress */
|
||||||
|
max_dictionary_size_c = 1 << max_dictionary_bits_c,
|
||||||
literal_context_bits = 3,
|
literal_context_bits = 3,
|
||||||
literal_pos_state_bits = 0, /* not used */
|
literal_pos_state_bits = 0, /* not used */
|
||||||
pos_state_bits = 2,
|
pos_state_bits = 2,
|
||||||
|
@ -66,9 +68,9 @@ static inline void Pp_init( struct Pretty_print * const pp,
|
||||||
pp->stdin_name = "(stdin)";
|
pp->stdin_name = "(stdin)";
|
||||||
pp->longest_name = 0;
|
pp->longest_name = 0;
|
||||||
pp->first_post = false;
|
pp->first_post = false;
|
||||||
stdin_name_len = strlen( pp->stdin_name );
|
|
||||||
|
|
||||||
if( verbosity <= 0 ) return;
|
if( verbosity <= 0 ) return;
|
||||||
|
stdin_name_len = strlen( pp->stdin_name );
|
||||||
for( i = 0; i < num_filenames; ++i )
|
for( i = 0; i < num_filenames; ++i )
|
||||||
{
|
{
|
||||||
const char * const s = filenames[i];
|
const char * const s = filenames[i];
|
||||||
|
@ -114,8 +116,10 @@ static inline void CRC32_update_buf( uint32_t * const crc,
|
||||||
const int size )
|
const int size )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
uint32_t c = *crc;
|
||||||
for( i = 0; i < size; ++i )
|
for( i = 0; i < size; ++i )
|
||||||
*crc = crc32[(*crc^buffer[i])&0xFF] ^ ( *crc >> 8 );
|
c = crc32[(c^buffer[i])&0xFF] ^ ( c >> 8 );
|
||||||
|
*crc = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,7 +179,7 @@ static inline bool Fh_set_dictionary_size( File_header data, const unsigned sz )
|
||||||
{
|
{
|
||||||
const unsigned base_size = 1 << data[5];
|
const unsigned base_size = 1 << data[5];
|
||||||
const unsigned fraction = base_size / 16;
|
const unsigned fraction = base_size / 16;
|
||||||
int i;
|
unsigned i;
|
||||||
for( i = 7; i >= 1; --i )
|
for( i = 7; i >= 1; --i )
|
||||||
if( base_size - ( i * fraction ) >= sz )
|
if( base_size - ( i * fraction ) >= sz )
|
||||||
{ data[5] |= ( i << 5 ); break; }
|
{ data[5] |= ( i << 5 ); break; }
|
||||||
|
@ -222,6 +226,8 @@ static inline void Ft_set_member_size( File_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; } }
|
||||||
|
|
||||||
|
|
||||||
|
static const char * const trailing_msg = "Trailing data not allowed.";
|
||||||
|
|
||||||
/* defined in main.c */
|
/* defined in main.c */
|
||||||
int readblock( const int fd, uint8_t * const buf, const int size );
|
int readblock( const int fd, uint8_t * const buf, const int size );
|
||||||
int writeblock( const int fd, const uint8_t * const buf, const int size );
|
int writeblock( const int fd, const uint8_t * const buf, const int size );
|
||||||
|
@ -230,6 +236,8 @@ int writeblock( const int fd, const uint8_t * const buf, const int size );
|
||||||
extern int verbosity;
|
extern int verbosity;
|
||||||
void cleanup_and_fail( const int retval );
|
void cleanup_and_fail( const int retval );
|
||||||
void show_error( const char * const msg, const int errcode, const bool help );
|
void show_error( const char * const msg, const int errcode, const bool help );
|
||||||
|
void show_file_error( const char * const filename, const char * const msg,
|
||||||
|
const int errcode );
|
||||||
void internal_error( const char * const msg );
|
void internal_error( const char * const msg );
|
||||||
|
|
||||||
#define SZ_OK 0
|
#define SZ_OK 0
|
||||||
|
|
99
main.c
99
main.c
|
@ -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-2016 Antonio Diaz Diaz.
|
Copyright (C) 2010-2017 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
|
||||||
|
@ -70,10 +70,10 @@ int verbosity = 0;
|
||||||
|
|
||||||
const char * const Program_name = "Pdlzip";
|
const char * const Program_name = "Pdlzip";
|
||||||
const char * const program_name = "pdlzip";
|
const char * const program_name = "pdlzip";
|
||||||
const char * const program_year = "2016";
|
const char * const program_year = "2017";
|
||||||
const char * invocation_name = 0;
|
const char * invocation_name = 0;
|
||||||
|
|
||||||
struct { const char * from; const char * to; } const known_extensions[] = {
|
const struct { const char * from; const char * to; } known_extensions[] = {
|
||||||
{ ".lz", "" },
|
{ ".lz", "" },
|
||||||
{ ".tlz", ".tar" },
|
{ ".tlz", ".tar" },
|
||||||
{ ".lzma", "" },
|
{ ".lzma", "" },
|
||||||
|
@ -98,7 +98,7 @@ static void show_help( void )
|
||||||
printf( "compressor also able to decompress legacy lzma-alone (.lzma) files.\n"
|
printf( "compressor also able to decompress legacy lzma-alone (.lzma) files.\n"
|
||||||
"\nLzma-alone is a very bad format; it is essentially a raw LZMA stream.\n"
|
"\nLzma-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"
|
||||||
"lzip format. Lziprecover can convert lzma-alone files to lzip format\n"
|
"lzip format. Lziprecover can convert some lzma-alone files to lzip format\n"
|
||||||
"without recompressing.\n"
|
"without recompressing.\n"
|
||||||
"\nUsage: %s [options] [files]\n", invocation_name );
|
"\nUsage: %s [options] [files]\n", invocation_name );
|
||||||
printf( "\nOptions:\n"
|
printf( "\nOptions:\n"
|
||||||
|
@ -154,9 +154,9 @@ static void show_header( const unsigned dictionary_size )
|
||||||
{
|
{
|
||||||
if( verbosity >= 3 )
|
if( verbosity >= 3 )
|
||||||
{
|
{
|
||||||
|
enum { factor = 1024 };
|
||||||
const char * const prefix[8] =
|
const char * const prefix[8] =
|
||||||
{ "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi" };
|
{ "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi" };
|
||||||
enum { factor = 1024 };
|
|
||||||
const char * p = "";
|
const char * p = "";
|
||||||
const char * np = " ";
|
const char * np = " ";
|
||||||
unsigned num = dictionary_size, i;
|
unsigned num = dictionary_size, i;
|
||||||
|
@ -165,7 +165,7 @@ static void show_header( const unsigned dictionary_size )
|
||||||
for( i = 0; i < 8 && ( num > 9999 || ( exact && num >= factor ) ); ++i )
|
for( i = 0; i < 8 && ( num > 9999 || ( exact && num >= factor ) ); ++i )
|
||||||
{ num /= factor; if( num % factor != 0 ) exact = false;
|
{ num /= factor; if( num % factor != 0 ) exact = false;
|
||||||
p = prefix[i]; np = ""; }
|
p = prefix[i]; np = ""; }
|
||||||
fprintf( stderr, "dictionary size %s%4u %sB. ", np, num, p );
|
fprintf( stderr, "dictionary %s%4u %sB. ", np, num, p );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ static unsigned long getnum( const char * const ptr,
|
||||||
|
|
||||||
if( !errno && tail[0] )
|
if( !errno && tail[0] )
|
||||||
{
|
{
|
||||||
const int factor = ( tail[1] == 'i' ) ? 1024 : 1000;
|
const unsigned factor = ( tail[1] == 'i' ) ? 1024 : 1000;
|
||||||
int exponent = 0; /* 0 = bad multiplier */
|
int exponent = 0; /* 0 = bad multiplier */
|
||||||
int i;
|
int i;
|
||||||
switch( tail[0] )
|
switch( tail[0] )
|
||||||
|
@ -225,25 +225,25 @@ static unsigned long getnum( const char * const ptr,
|
||||||
static int get_dict_size( const char * const arg )
|
static int get_dict_size( const char * const arg )
|
||||||
{
|
{
|
||||||
char * tail;
|
char * tail;
|
||||||
const int bits = strtol( arg, &tail, 0 );
|
const long bits = strtol( arg, &tail, 0 );
|
||||||
if( bits >= min_dictionary_bits &&
|
if( bits >= min_dictionary_bits &&
|
||||||
bits <= max_dictionary_bits && *tail == 0 )
|
bits <= max_dictionary_bits_c && *tail == 0 )
|
||||||
return ( 1 << bits );
|
return ( 1 << bits );
|
||||||
return getnum( arg, min_dictionary_size, max_dictionary_size );
|
return getnum( arg, min_dictionary_size, max_dictionary_size_c );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int extension_index( const char * const name )
|
static int extension_index( const char * const name )
|
||||||
{
|
{
|
||||||
int i;
|
int eindex;
|
||||||
for( i = 0; known_extensions[i].from; ++i )
|
for( eindex = 0; known_extensions[eindex].from; ++eindex )
|
||||||
{
|
{
|
||||||
const char * const ext = known_extensions[i].from;
|
const char * const ext = known_extensions[eindex].from;
|
||||||
const unsigned name_len = strlen( name );
|
const unsigned name_len = strlen( name );
|
||||||
const unsigned ext_len = strlen( ext );
|
const unsigned ext_len = strlen( ext );
|
||||||
if( name_len > ext_len &&
|
if( name_len > ext_len &&
|
||||||
strncmp( name + name_len - ext_len, ext, ext_len ) == 0 )
|
strncmp( name + name_len - ext_len, ext, ext_len ) == 0 )
|
||||||
return i;
|
return eindex;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -264,11 +264,7 @@ static int open_instream( const char * const name, struct stat * const in_statsp
|
||||||
{
|
{
|
||||||
infd = open( name, O_RDONLY | O_BINARY );
|
infd = open( name, O_RDONLY | O_BINARY );
|
||||||
if( infd < 0 )
|
if( infd < 0 )
|
||||||
{
|
show_file_error( name, "Can't open input file", errno );
|
||||||
if( verbosity >= 0 )
|
|
||||||
fprintf( stderr, "%s: Can't open input file '%s': %s\n",
|
|
||||||
program_name, name, strerror( errno ) );
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const int i = fstat( infd, in_statsp );
|
const int i = fstat( infd, in_statsp );
|
||||||
|
@ -294,7 +290,7 @@ static int open_instream( const char * const name, struct stat * const in_statsp
|
||||||
|
|
||||||
|
|
||||||
/* assure at least a minimum size for buffer 'buf' */
|
/* assure at least a minimum size for buffer 'buf' */
|
||||||
static void * resize_buffer( void * buf, const int min_size )
|
static void * resize_buffer( void * buf, const unsigned min_size )
|
||||||
{
|
{
|
||||||
if( buf ) buf = realloc( buf, min_size );
|
if( buf ) buf = realloc( buf, min_size );
|
||||||
else buf = malloc( min_size );
|
else buf = malloc( min_size );
|
||||||
|
@ -316,19 +312,19 @@ static void set_c_outname( const char * const name )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void set_d_outname( const char * const name, const int i )
|
static void set_d_outname( const char * const name, const int eindex )
|
||||||
{
|
{
|
||||||
const unsigned name_len = strlen( name );
|
const unsigned name_len = strlen( name );
|
||||||
if( i >= 0 )
|
if( eindex >= 0 )
|
||||||
{
|
{
|
||||||
const char * const from = known_extensions[i].from;
|
const char * const from = known_extensions[eindex].from;
|
||||||
const unsigned from_len = strlen( from );
|
const unsigned from_len = strlen( from );
|
||||||
if( name_len > from_len )
|
if( name_len > from_len )
|
||||||
{
|
{
|
||||||
output_filename = resize_buffer( output_filename, name_len +
|
output_filename = resize_buffer( output_filename, name_len +
|
||||||
strlen( known_extensions[0].to ) + 1 );
|
strlen( known_extensions[eindex].to ) + 1 );
|
||||||
strcpy( output_filename, name );
|
strcpy( output_filename, name );
|
||||||
strcpy( output_filename + name_len - from_len, known_extensions[i].to );
|
strcpy( output_filename + name_len - from_len, known_extensions[eindex].to );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -364,7 +360,8 @@ static bool open_outstream( const bool force, const bool from_stdin )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool check_tty( const int infd, const enum Mode program_mode )
|
static bool check_tty( const char * const input_filename, const int infd,
|
||||||
|
const enum Mode program_mode )
|
||||||
{
|
{
|
||||||
if( program_mode == m_compress && isatty( outfd ) )
|
if( program_mode == m_compress && isatty( outfd ) )
|
||||||
{
|
{
|
||||||
|
@ -374,7 +371,8 @@ static bool check_tty( const int infd, const enum Mode program_mode )
|
||||||
if( ( program_mode == m_decompress || program_mode == m_test ) &&
|
if( ( program_mode == m_decompress || program_mode == m_test ) &&
|
||||||
isatty( infd ) )
|
isatty( infd ) )
|
||||||
{
|
{
|
||||||
show_error( "I won't read compressed data from a terminal.", 0, true );
|
show_file_error( input_filename,
|
||||||
|
"I won't read compressed data from a terminal.", 0 );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -432,7 +430,7 @@ static void close_and_set_permissions( const struct stat * const in_statsp )
|
||||||
|
|
||||||
|
|
||||||
static int compress( const struct Lzma_options * const encoder_options,
|
static int compress( const struct Lzma_options * const encoder_options,
|
||||||
const int infd, struct Pretty_print * const pp )
|
struct Pretty_print * const pp, const int infd )
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
CLzmaEncHandle encoder = 0;
|
CLzmaEncHandle encoder = 0;
|
||||||
|
@ -604,9 +602,8 @@ static int lzip_decode( CLzmaDec *decoder, const int infd, uint8_t inBuf[],
|
||||||
{
|
{
|
||||||
error = true;
|
error = true;
|
||||||
if( verbosity >= 0 )
|
if( verbosity >= 0 )
|
||||||
fprintf( stderr, "Trailer truncated at trailer position %u;"
|
fprintf( stderr, "Trailer truncated at trailer position %d;"
|
||||||
" some checks may fail.\n",
|
" some checks may fail.\n", *inSize - *inPos );
|
||||||
(unsigned)(*inSize - *inPos) );
|
|
||||||
for( i = *inSize - *inPos; i < Ft_size; ++i )
|
for( i = *inSize - *inPos; i < Ft_size; ++i )
|
||||||
inBuf[*inPos+i] = 0;
|
inBuf[*inPos+i] = 0;
|
||||||
}
|
}
|
||||||
|
@ -641,7 +638,7 @@ static int lzip_decode( CLzmaDec *decoder, const int infd, uint8_t inBuf[],
|
||||||
( 8.0 * total_in ) / total_out,
|
( 8.0 * total_in ) / total_out,
|
||||||
100.0 * ( 1.0 - ( (double)total_in / total_out ) ) );
|
100.0 * ( 1.0 - ( (double)total_in / total_out ) ) );
|
||||||
if( !error && verbosity >= 4 )
|
if( !error && verbosity >= 4 )
|
||||||
fprintf( stderr, "data CRC %08X, data size %9llu, member size %8llu. ",
|
fprintf( stderr, "CRC %08X, decompressed %9llu, compressed %8llu. ",
|
||||||
crc, total_out, total_in );
|
crc, total_out, total_in );
|
||||||
if( error ) return 2;
|
if( error ) return 2;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -677,6 +674,8 @@ static int decompress( const int infd, struct Pretty_print * const pp,
|
||||||
if( first_member || Fh_verify_prefix( header, size ) )
|
if( first_member || Fh_verify_prefix( header, size ) )
|
||||||
{ Pp_show_msg( pp, "File ends unexpectedly at member header." );
|
{ Pp_show_msg( pp, "File ends unexpectedly at member header." );
|
||||||
retval = 2; }
|
retval = 2; }
|
||||||
|
else if( size > 0 && !ignore_trailing )
|
||||||
|
{ show_file_error( pp->name, trailing_msg, 0 ); retval = 2; }
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if( !Fh_verify_magic( header ) )
|
if( !Fh_verify_magic( header ) )
|
||||||
|
@ -684,7 +683,7 @@ static int decompress( const int infd, struct Pretty_print * const pp,
|
||||||
if( !first_member )
|
if( !first_member )
|
||||||
{
|
{
|
||||||
if( !ignore_trailing )
|
if( !ignore_trailing )
|
||||||
{ Pp_show_msg( pp, "Trailing data not allowed." ); retval = 2; }
|
{ show_file_error( pp->name, trailing_msg, 0 ); retval = 2; }
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if( inSize - inPos >= lzma_header_size - Fh_size ) /* try lzma-alone */
|
if( inSize - inPos >= lzma_header_size - Fh_size ) /* try lzma-alone */
|
||||||
|
@ -704,7 +703,8 @@ static int decompress( const int infd, struct Pretty_print * const pp,
|
||||||
}
|
}
|
||||||
if( lzip_mode )
|
if( lzip_mode )
|
||||||
{
|
{
|
||||||
Pp_show_msg( pp, "Bad magic number (file not in lzip format)." );
|
show_file_error( pp->name,
|
||||||
|
"Bad magic number (file not in lzip format).", 0 );
|
||||||
retval = 2; break;
|
retval = 2; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -839,6 +839,16 @@ void show_error( const char * const msg, const int errcode, const bool help )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void show_file_error( const char * const filename, const char * const msg,
|
||||||
|
const int errcode )
|
||||||
|
{
|
||||||
|
if( verbosity < 0 ) return;
|
||||||
|
fprintf( stderr, "%s: %s: %s", program_name, filename, msg );
|
||||||
|
if( errcode > 0 ) fprintf( stderr, ": %s", strerror( errcode ) );
|
||||||
|
fputc( '\n', stderr );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void internal_error( const char * const msg )
|
void internal_error( const char * const msg )
|
||||||
{
|
{
|
||||||
if( verbosity >= 0 )
|
if( verbosity >= 0 )
|
||||||
|
@ -864,7 +874,6 @@ int main( const int argc, const char * const argv[] )
|
||||||
{ 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" */
|
struct Lzma_options encoder_options = option_mapping[6]; /* default = "-6" */
|
||||||
const char * input_filename = "";
|
|
||||||
const char * default_output_filename = "";
|
const char * default_output_filename = "";
|
||||||
const char ** filenames = 0;
|
const char ** filenames = 0;
|
||||||
int num_filenames = 0;
|
int num_filenames = 0;
|
||||||
|
@ -877,8 +886,8 @@ int main( const int argc, const char * const argv[] )
|
||||||
bool force = false;
|
bool force = false;
|
||||||
bool ignore_trailing = true;
|
bool ignore_trailing = true;
|
||||||
bool keep_input_files = false;
|
bool keep_input_files = false;
|
||||||
bool stdin_used = false;
|
|
||||||
bool recompress = false;
|
bool recompress = false;
|
||||||
|
bool stdin_used = false;
|
||||||
bool to_stdout = false;
|
bool to_stdout = false;
|
||||||
struct Pretty_print pp;
|
struct Pretty_print pp;
|
||||||
|
|
||||||
|
@ -961,9 +970,6 @@ int main( const int argc, const char * const argv[] )
|
||||||
setmode( STDOUT_FILENO, O_BINARY );
|
setmode( STDOUT_FILENO, O_BINARY );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( program_mode == m_test )
|
|
||||||
outfd = -1;
|
|
||||||
|
|
||||||
num_filenames = max( 1, ap_arguments( &parser ) - argind );
|
num_filenames = max( 1, ap_arguments( &parser ) - argind );
|
||||||
filenames = resize_buffer( filenames, num_filenames * sizeof filenames[0] );
|
filenames = resize_buffer( filenames, num_filenames * sizeof filenames[0] );
|
||||||
filenames[0] = "-";
|
filenames[0] = "-";
|
||||||
|
@ -974,6 +980,9 @@ int main( const int argc, const char * const argv[] )
|
||||||
if( strcmp( filenames[i], "-" ) != 0 ) filenames_given = true;
|
if( strcmp( filenames[i], "-" ) != 0 ) filenames_given = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( program_mode == m_test )
|
||||||
|
outfd = -1;
|
||||||
|
|
||||||
if( !to_stdout && program_mode != m_test &&
|
if( !to_stdout && program_mode != m_test &&
|
||||||
( filenames_given || default_output_filename[0] ) )
|
( filenames_given || default_output_filename[0] ) )
|
||||||
set_signals();
|
set_signals();
|
||||||
|
@ -983,6 +992,7 @@ int main( const int argc, const char * const argv[] )
|
||||||
output_filename = resize_buffer( output_filename, 1 );
|
output_filename = resize_buffer( output_filename, 1 );
|
||||||
for( i = 0; i < num_filenames; ++i )
|
for( i = 0; i < num_filenames; ++i )
|
||||||
{
|
{
|
||||||
|
const char * input_filename = "";
|
||||||
int tmp;
|
int tmp;
|
||||||
struct stat in_stats;
|
struct stat in_stats;
|
||||||
const struct stat * in_statsp;
|
const struct stat * in_statsp;
|
||||||
|
@ -991,7 +1001,6 @@ int main( const int argc, const char * const argv[] )
|
||||||
if( !filenames[i][0] || strcmp( filenames[i], "-" ) == 0 )
|
if( !filenames[i][0] || strcmp( filenames[i], "-" ) == 0 )
|
||||||
{
|
{
|
||||||
if( stdin_used ) continue; else stdin_used = true;
|
if( stdin_used ) continue; else stdin_used = true;
|
||||||
input_filename = "";
|
|
||||||
infd = STDIN_FILENO;
|
infd = STDIN_FILENO;
|
||||||
if( program_mode != m_test )
|
if( program_mode != m_test )
|
||||||
{
|
{
|
||||||
|
@ -1018,8 +1027,7 @@ int main( const int argc, const char * const argv[] )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const int eindex = extension_index( filenames[i] );
|
const int eindex = extension_index( input_filename = filenames[i] );
|
||||||
input_filename = filenames[i];
|
|
||||||
infd = open_instream( input_filename, &in_stats, program_mode,
|
infd = open_instream( input_filename, &in_stats, program_mode,
|
||||||
eindex, recompress, to_stdout );
|
eindex, recompress, to_stdout );
|
||||||
if( infd < 0 ) { if( retval < 1 ) retval = 1; continue; }
|
if( infd < 0 ) { if( retval < 1 ) retval = 1; continue; }
|
||||||
|
@ -1041,16 +1049,17 @@ int main( const int argc, const char * const argv[] )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !check_tty( infd, program_mode ) )
|
Pp_set_name( &pp, input_filename );
|
||||||
|
if( !check_tty( pp.name, infd, program_mode ) )
|
||||||
{
|
{
|
||||||
if( retval < 1 ) retval = 1;
|
if( retval < 1 ) retval = 1;
|
||||||
|
if( program_mode == m_test ) { close( infd ); infd = -1; continue; }
|
||||||
cleanup_and_fail( retval );
|
cleanup_and_fail( retval );
|
||||||
}
|
}
|
||||||
|
|
||||||
in_statsp = input_filename[0] ? &in_stats : 0;
|
in_statsp = input_filename[0] ? &in_stats : 0;
|
||||||
Pp_set_name( &pp, input_filename );
|
|
||||||
if( program_mode == m_compress )
|
if( program_mode == m_compress )
|
||||||
tmp = compress( &encoder_options, infd, &pp );
|
tmp = compress( &encoder_options, &pp, infd );
|
||||||
else
|
else
|
||||||
tmp = decompress( infd, &pp, ignore_trailing, program_mode == m_test );
|
tmp = decompress( infd, &pp, ignore_trailing, program_mode == m_test );
|
||||||
if( tmp > retval ) retval = tmp;
|
if( tmp > retval ) retval = tmp;
|
||||||
|
|
|
@ -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-2016 Antonio Diaz Diaz.
|
# Copyright (C) 2010-2017 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.
|
||||||
|
@ -17,12 +17,12 @@ if [ ! -f "${LZIP}" ] || [ ! -x "${LZIP}" ] ; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e "${LZIP}" ] 2> /dev/null ; then true
|
[ -e "${LZIP}" ] 2> /dev/null ||
|
||||||
else
|
{
|
||||||
echo "$0: a POSIX shell is required to run the tests"
|
echo "$0: a POSIX shell is required to run the tests"
|
||||||
echo "Try bash -c \"$0 $1 $2\""
|
echo "Try bash -c \"$0 $1 $2\""
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
}
|
||||||
|
|
||||||
if [ -d tmp ] ; then rm -rf tmp ; fi
|
if [ -d tmp ] ; then rm -rf tmp ; fi
|
||||||
mkdir tmp
|
mkdir tmp
|
||||||
|
@ -31,149 +31,192 @@ cd "${objdir}"/tmp || framework_failure
|
||||||
cat "${testdir}"/test.txt > in || framework_failure
|
cat "${testdir}"/test.txt > in || framework_failure
|
||||||
in_lz="${testdir}"/test.txt.lz
|
in_lz="${testdir}"/test.txt.lz
|
||||||
fail=0
|
fail=0
|
||||||
|
test_failed() { fail=1 ; printf " $1" ; [ -z "$2" ] || printf "($2)" ; }
|
||||||
|
|
||||||
printf "testing pdlzip-%s..." "$2"
|
printf "testing pdlzip-%s..." "$2"
|
||||||
|
|
||||||
"${LZIP}" -fkqm4 in
|
"${LZIP}" -fkqm4 in
|
||||||
if [ $? = 1 ] && [ ! -e in.lz ] ; then printf . ; else printf - ; fail=1 ; fi
|
{ [ $? = 1 ] && [ ! -e in.lz ] ; } || test_failed $LINENO
|
||||||
"${LZIP}" -fkqm274 in
|
"${LZIP}" -fkqm274 in
|
||||||
if [ $? = 1 ] && [ ! -e in.lz ] ; then printf . ; else printf - ; fail=1 ; fi
|
{ [ $? = 1 ] && [ ! -e in.lz ] ; } || test_failed $LINENO
|
||||||
"${LZIP}" -fkqs-1 in
|
for i in bad_size -1 0 4095 513MiB 1G 1T 1P 1E 1Z 1Y 10KB ; do
|
||||||
if [ $? = 1 ] && [ ! -e in.lz ] ; then printf . ; else printf - ; fail=1 ; fi
|
"${LZIP}" -fkqs $i in
|
||||||
"${LZIP}" -fkqs0 in
|
{ [ $? = 1 ] && [ ! -e in.lz ] ; } || test_failed $LINENO $i
|
||||||
if [ $? = 1 ] && [ ! -e in.lz ] ; then printf . ; else printf - ; fail=1 ; fi
|
done
|
||||||
"${LZIP}" -fkqs4095 in
|
|
||||||
if [ $? = 1 ] && [ ! -e in.lz ] ; then printf . ; else printf - ; fail=1 ; fi
|
|
||||||
"${LZIP}" -fkqs513MiB in
|
|
||||||
if [ $? = 1 ] && [ ! -e in.lz ] ; then printf . ; else printf - ; fail=1 ; fi
|
|
||||||
"${LZIP}" -tq in
|
"${LZIP}" -tq in
|
||||||
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
|
[ $? = 2 ] || test_failed $LINENO
|
||||||
"${LZIP}" -tq < in
|
"${LZIP}" -tq < in
|
||||||
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
|
[ $? = 2 ] || test_failed $LINENO
|
||||||
"${LZIP}" -cdq in
|
"${LZIP}" -cdq in
|
||||||
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
|
[ $? = 2 ] || test_failed $LINENO
|
||||||
"${LZIP}" -cdq < in
|
"${LZIP}" -cdq < in
|
||||||
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
|
[ $? = 2 ] || test_failed $LINENO
|
||||||
dd if="${in_lz}" bs=1 count=6 2> /dev/null | "${LZIP}" -tq
|
# these are for code coverage
|
||||||
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
|
"${LZIP}" -t -- nx_file 2> /dev/null
|
||||||
dd if="${in_lz}" bs=1 count=20 2> /dev/null | "${LZIP}" -tq
|
[ $? = 1 ] || test_failed $LINENO
|
||||||
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
|
"${LZIP}" --help > /dev/null || test_failed $LINENO
|
||||||
|
"${LZIP}" -n1 -V > /dev/null || test_failed $LINENO
|
||||||
|
"${LZIP}" -m 2> /dev/null
|
||||||
|
[ $? = 1 ] || test_failed $LINENO
|
||||||
|
"${LZIP}" -z 2> /dev/null
|
||||||
|
[ $? = 1 ] || test_failed $LINENO
|
||||||
|
"${LZIP}" --bad_option 2> /dev/null
|
||||||
|
[ $? = 1 ] || test_failed $LINENO
|
||||||
|
"${LZIP}" --t 2> /dev/null
|
||||||
|
[ $? = 1 ] || test_failed $LINENO
|
||||||
|
"${LZIP}" --test=2 2> /dev/null
|
||||||
|
[ $? = 1 ] || test_failed $LINENO
|
||||||
|
"${LZIP}" --output= 2> /dev/null
|
||||||
|
[ $? = 1 ] || test_failed $LINENO
|
||||||
|
"${LZIP}" --output 2> /dev/null
|
||||||
|
[ $? = 1 ] || test_failed $LINENO
|
||||||
|
printf "LZIP\001-.............................." | "${LZIP}" -t 2> /dev/null
|
||||||
|
printf "LZIP\002-.............................." | "${LZIP}" -t 2> /dev/null
|
||||||
|
printf "LZIP\001+.............................." | "${LZIP}" -t 2> /dev/null
|
||||||
|
|
||||||
printf "\ntesting decompression..."
|
printf "\ntesting decompression..."
|
||||||
|
|
||||||
"${LZIP}" -t "${in_lz}"
|
"${LZIP}" -t "${in_lz}" || test_failed $LINENO
|
||||||
if [ $? = 0 ] ; then printf . ; else printf - ; fail=1 ; fi
|
"${LZIP}" -cd "${in_lz}" > copy || test_failed $LINENO
|
||||||
"${LZIP}" -cd "${in_lz}" > copy || fail=1
|
cmp in copy || test_failed $LINENO
|
||||||
cmp in copy || fail=1
|
|
||||||
printf .
|
|
||||||
|
|
||||||
"${LZIP}" -t "${testdir}"/test.txt.lzma
|
"${LZIP}" -t "${testdir}"/test.txt.lzma || test_failed $LINENO
|
||||||
if [ $? = 0 ] ; then printf . ; else printf - ; fail=1 ; fi
|
"${LZIP}" -cd "${testdir}"/test.txt.lzma > copy || test_failed $LINENO
|
||||||
"${LZIP}" -cd "${testdir}"/test.txt.lzma > copy || fail=1
|
cmp in copy || test_failed $LINENO
|
||||||
cmp in copy || fail=1
|
|
||||||
printf .
|
|
||||||
|
|
||||||
rm -f copy
|
rm -f copy
|
||||||
cat "${in_lz}" > copy.lz || framework_failure
|
cat "${in_lz}" > copy.lz || framework_failure
|
||||||
"${LZIP}" -dk copy.lz || fail=1
|
"${LZIP}" -dk copy.lz || test_failed $LINENO
|
||||||
cmp in copy || fail=1
|
cmp in copy || test_failed $LINENO
|
||||||
printf "to be overwritten" > copy || framework_failure
|
printf "to be overwritten" > copy || framework_failure
|
||||||
"${LZIP}" -dq copy.lz
|
"${LZIP}" -d copy.lz 2> /dev/null
|
||||||
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
|
[ $? = 1 ] || test_failed $LINENO
|
||||||
"${LZIP}" -df copy.lz
|
"${LZIP}" -df copy.lz
|
||||||
if [ $? = 0 ] && [ ! -e copy.lz ] && cmp in copy ; then
|
{ [ $? = 0 ] && [ ! -e copy.lz ] && cmp in copy ; } || test_failed $LINENO
|
||||||
printf . ; else printf - ; fail=1 ; fi
|
|
||||||
|
|
||||||
printf "to be overwritten" > copy || framework_failure
|
printf "to be overwritten" > copy || framework_failure
|
||||||
"${LZIP}" -df -o copy < "${in_lz}" || fail=1
|
"${LZIP}" -df -o copy < "${in_lz}" || test_failed $LINENO
|
||||||
cmp in copy || fail=1
|
cmp in copy || test_failed $LINENO
|
||||||
printf .
|
|
||||||
|
|
||||||
rm -f copy
|
rm -f copy
|
||||||
"${LZIP}" -s16 < in > anyothername || fail=1
|
"${LZIP}" -s16 < in > anyothername || test_failed $LINENO
|
||||||
"${LZIP}" -d -o copy - anyothername - < "${in_lz}"
|
"${LZIP}" -dv --output copy - anyothername - < "${in_lz}" 2> /dev/null
|
||||||
if [ $? = 0 ] && cmp in copy && cmp in anyothername.out ; then
|
{ [ $? = 0 ] && cmp in copy && cmp in anyothername.out ; } ||
|
||||||
printf . ; else printf - ; fail=1 ; fi
|
test_failed $LINENO
|
||||||
rm -f copy anyothername.out
|
rm -f copy anyothername.out
|
||||||
|
|
||||||
"${LZIP}" -tq in "${in_lz}"
|
"${LZIP}" -tq in "${in_lz}"
|
||||||
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
|
[ $? = 2 ] || test_failed $LINENO
|
||||||
"${LZIP}" -tq foo.lz "${in_lz}"
|
"${LZIP}" -tq nx_file.lz "${in_lz}"
|
||||||
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
|
[ $? = 1 ] || test_failed $LINENO
|
||||||
"${LZIP}" -cdq in "${in_lz}" > copy
|
"${LZIP}" -cdq in "${in_lz}" > copy
|
||||||
if [ $? = 2 ] && cat copy in | cmp in - ; then printf . ; else printf - ; fail=1 ; fi
|
{ [ $? = 2 ] && cat copy in | cmp in - ; } || test_failed $LINENO
|
||||||
"${LZIP}" -cdq foo.lz "${in_lz}" > copy
|
"${LZIP}" -cdq nx_file.lz "${in_lz}" > copy
|
||||||
if [ $? = 1 ] && cmp in copy ; then printf . ; else printf - ; fail=1 ; fi
|
{ [ $? = 1 ] && cmp in copy ; } || test_failed $LINENO
|
||||||
rm -f copy
|
rm -f copy
|
||||||
cat "${in_lz}" > copy.lz || framework_failure
|
cat "${in_lz}" > copy.lz || framework_failure
|
||||||
|
for i in 1 2 3 4 5 6 7 ; do
|
||||||
|
printf "g" >> copy.lz || framework_failure
|
||||||
|
"${LZIP}" -atvvvv copy.lz "${in_lz}" 2> /dev/null
|
||||||
|
[ $? = 2 ] || test_failed $LINENO $i
|
||||||
|
done
|
||||||
"${LZIP}" -dq in copy.lz
|
"${LZIP}" -dq in copy.lz
|
||||||
if [ $? = 2 ] && [ -e copy.lz ] && [ ! -e copy ] && [ ! -e in.out ] ; then
|
{ [ $? = 2 ] && [ -e copy.lz ] && [ ! -e copy ] && [ ! -e in.out ] ; } ||
|
||||||
printf . ; else printf - ; fail=1 ; fi
|
test_failed $LINENO
|
||||||
"${LZIP}" -dq foo.lz copy.lz
|
"${LZIP}" -dq nx_file.lz copy.lz
|
||||||
if [ $? = 1 ] && [ ! -e copy.lz ] && [ ! -e foo ] && cmp in copy ; then
|
{ [ $? = 1 ] && [ ! -e copy.lz ] && [ ! -e nx_file ] && cmp in copy ; } ||
|
||||||
printf . ; else printf - ; fail=1 ; fi
|
test_failed $LINENO
|
||||||
|
|
||||||
cat in in > in2 || framework_failure
|
cat in in > in2 || framework_failure
|
||||||
"${LZIP}" -s16 -o copy2 < in2 || fail=1
|
cat "${in_lz}" "${in_lz}" > in2.lz || framework_failure
|
||||||
"${LZIP}" -t copy2.lz || fail=1
|
"${LZIP}" -t in2.lz || test_failed $LINENO
|
||||||
"${LZIP}" -cd copy2.lz > copy2 || fail=1
|
"${LZIP}" -cd in2.lz > copy2 || test_failed $LINENO
|
||||||
cmp in2 copy2 || fail=1
|
cmp in2 copy2 || test_failed $LINENO
|
||||||
printf .
|
|
||||||
|
|
||||||
printf "garbage" >> copy2.lz || framework_failure
|
"${LZIP}" -s16 --output=copy2 < in2 || test_failed $LINENO
|
||||||
|
"${LZIP}" -t copy2.lz || test_failed $LINENO
|
||||||
|
"${LZIP}" -cd copy2.lz > copy2 || test_failed $LINENO
|
||||||
|
cmp in2 copy2 || test_failed $LINENO
|
||||||
|
|
||||||
|
printf "\ngarbage" >> copy2.lz || framework_failure
|
||||||
|
"${LZIP}" -tvvvv copy2.lz 2> /dev/null || test_failed $LINENO
|
||||||
rm -f copy2
|
rm -f copy2
|
||||||
"${LZIP}" -atq copy2.lz
|
"${LZIP}" -atq copy2.lz
|
||||||
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
|
[ $? = 2 ] || test_failed $LINENO
|
||||||
"${LZIP}" -atq < copy2.lz
|
"${LZIP}" -atq < copy2.lz
|
||||||
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
|
[ $? = 2 ] || test_failed $LINENO
|
||||||
"${LZIP}" -adkq copy2.lz
|
"${LZIP}" -adkq copy2.lz
|
||||||
if [ $? = 2 ] && [ ! -e copy2 ] ; then printf . ; else printf - ; fail=1 ; fi
|
{ [ $? = 2 ] && [ ! -e copy2 ] ; } || test_failed $LINENO
|
||||||
"${LZIP}" -adkq -o copy2 < copy2.lz
|
"${LZIP}" -adkq -o copy2 < copy2.lz
|
||||||
if [ $? = 2 ] && [ ! -e copy2 ] ; then printf . ; else printf - ; fail=1 ; fi
|
{ [ $? = 2 ] && [ ! -e copy2 ] ; } || test_failed $LINENO
|
||||||
printf "to be overwritten" > copy2 || framework_failure
|
printf "to be overwritten" > copy2 || framework_failure
|
||||||
"${LZIP}" -df copy2.lz || fail=1
|
"${LZIP}" -df copy2.lz || test_failed $LINENO
|
||||||
cmp in2 copy2 || fail=1
|
cmp in2 copy2 || test_failed $LINENO
|
||||||
printf .
|
|
||||||
|
|
||||||
printf "\ntesting compression..."
|
printf "\ntesting compression..."
|
||||||
|
|
||||||
"${LZIP}" -cfq "${in_lz}" > out # /dev/null is a tty on OS/2
|
"${LZIP}" -cf "${in_lz}" > out 2> /dev/null # /dev/null is a tty on OS/2
|
||||||
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
|
[ $? = 1 ] || test_failed $LINENO
|
||||||
"${LZIP}" -cF -s16 "${in_lz}" > out || fail=1
|
"${LZIP}" -cFvvm36 -s16 "${in_lz}" > out 2> /dev/null || test_failed $LINENO
|
||||||
"${LZIP}" -cd out | "${LZIP}" -d > copy || fail=1
|
"${LZIP}" -cd out | "${LZIP}" -d > copy || test_failed $LINENO
|
||||||
cmp in copy || fail=1
|
cmp in copy || test_failed $LINENO
|
||||||
printf .
|
|
||||||
|
|
||||||
for i in s4Ki 0 1 2 3 4 5 6 7 8 9 ; do
|
for i in s4Ki 0 1 2 3 4 5 6 7 8 9 ; do
|
||||||
"${LZIP}" -k -$i -s16 in || fail=1
|
"${LZIP}" -k -$i -s16 in || test_failed $LINENO $i
|
||||||
mv -f in.lz copy.lz || fail=1
|
mv -f in.lz copy.lz || test_failed $LINENO $i
|
||||||
printf "garbage" >> copy.lz || fail=1
|
printf "garbage" >> copy.lz || framework_failure
|
||||||
"${LZIP}" -df copy.lz || fail=1
|
"${LZIP}" -df copy.lz || test_failed $LINENO $i
|
||||||
cmp in copy || fail=1
|
cmp in copy || test_failed $LINENO $i
|
||||||
done
|
done
|
||||||
printf .
|
|
||||||
|
|
||||||
for i in s4Ki 0 1 2 3 4 5 6 7 8 9 ; do
|
for i in s4Ki 0 1 2 3 4 5 6 7 8 9 ; do
|
||||||
"${LZIP}" -c -$i -s16 in > out || fail=1
|
"${LZIP}" -c -$i -s16 in > out || test_failed $LINENO $i
|
||||||
printf "g" >> out || fail=1
|
printf "g" >> out || framework_failure
|
||||||
"${LZIP}" -cd out > copy || fail=1
|
"${LZIP}" -cd out > copy || test_failed $LINENO $i
|
||||||
cmp in copy || fail=1
|
cmp in copy || test_failed $LINENO $i
|
||||||
done
|
done
|
||||||
printf .
|
|
||||||
|
|
||||||
for i in s4Ki 0 1 2 3 4 5 6 7 8 9 ; do
|
for i in s4Ki 0 1 2 3 4 5 6 7 8 9 ; do
|
||||||
"${LZIP}" -$i -s16 < in > out || fail=1
|
"${LZIP}" -$i -s16 < in > out || test_failed $LINENO $i
|
||||||
"${LZIP}" -d < out > copy || fail=1
|
"${LZIP}" -d < out > copy || test_failed $LINENO $i
|
||||||
cmp in copy || fail=1
|
cmp in copy || test_failed $LINENO $i
|
||||||
done
|
done
|
||||||
printf .
|
|
||||||
|
|
||||||
for i in s4Ki 0 1 2 3 4 5 6 7 8 9 ; do
|
for i in s4Ki 0 1 2 3 4 5 6 7 8 9 ; do
|
||||||
"${LZIP}" -f -$i -s16 -o out < in || fail=1
|
"${LZIP}" -f -$i -s16 -o out < in || test_failed $LINENO $i
|
||||||
"${LZIP}" -df -o copy < out.lz || fail=1
|
"${LZIP}" -df -o copy < out.lz || test_failed $LINENO $i
|
||||||
cmp in copy || fail=1
|
cmp in copy || test_failed $LINENO $i
|
||||||
done
|
done
|
||||||
printf .
|
|
||||||
|
printf "\ntesting bad input..."
|
||||||
|
|
||||||
|
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
|
||||||
|
for i in 6 20 14734 14753 14754 14755 14756 14757 14758 ; do
|
||||||
|
dd if=in3.lz of=trunc.lz bs=$i count=1 2> /dev/null
|
||||||
|
"${LZIP}" -t trunc.lz 2> /dev/null
|
||||||
|
[ $? = 2 ] || test_failed $LINENO $i
|
||||||
|
"${LZIP}" -tq < trunc.lz
|
||||||
|
[ $? = 2 ] || test_failed $LINENO $i
|
||||||
|
"${LZIP}" -cdq trunc.lz > out
|
||||||
|
[ $? = 2 ] || test_failed $LINENO $i
|
||||||
|
"${LZIP}" -dq < trunc.lz > out
|
||||||
|
[ $? = 2 ] || test_failed $LINENO $i
|
||||||
|
done
|
||||||
|
else
|
||||||
|
printf "\nwarning: skipping truncation test: 'dd' does not work on your system."
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat "${in_lz}" > ingin.lz || framework_failure
|
||||||
|
printf "g" >> ingin.lz || framework_failure
|
||||||
|
cat "${in_lz}" >> ingin.lz || framework_failure
|
||||||
|
"${LZIP}" -t ingin.lz || test_failed $LINENO
|
||||||
|
"${LZIP}" -cd ingin.lz > copy || test_failed $LINENO
|
||||||
|
cmp in copy || test_failed $LINENO
|
||||||
|
"${LZIP}" -t < ingin.lz || test_failed $LINENO
|
||||||
|
"${LZIP}" -d < ingin.lz > copy || test_failed $LINENO
|
||||||
|
cmp in copy || test_failed $LINENO
|
||||||
|
|
||||||
echo
|
echo
|
||||||
if [ ${fail} = 0 ] ; then
|
if [ ${fail} = 0 ] ; then
|
||||||
|
|
Loading…
Add table
Reference in a new issue