1
0
Fork 0

Adding upstream version 1.5~rc1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-17 20:28:13 +01:00
parent dc4a5bce30
commit e50395668c
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
13 changed files with 119 additions and 100 deletions

View file

@ -4,4 +4,4 @@ The ideas embodied in clzip are due to (at least) the following people:
Abraham Lempel and Jacob Ziv (for the LZ algorithm), Andrey Markov (for Abraham Lempel and Jacob Ziv (for the LZ algorithm), Andrey Markov (for
the definition of Markov chains), G.N.N. Martin (for the definition of the definition of Markov chains), G.N.N. Martin (for the definition of
range encoding), Igor Pavlov (for putting all the above together in range encoding), Igor Pavlov (for putting all the above together in
LZMA), and Julian Seward (for bzip2's CLI and the idea of unzcrash). LZMA), and Julian Seward (for bzip2's CLI).

View file

@ -1,3 +1,9 @@
2013-08-01 Antonio Diaz Diaz <antonio@gnu.org>
* Version 1.5-rc1 released.
* main.c (show_header): Do not show header version.
* Minor fixes.
2013-07-17 Antonio Diaz Diaz <antonio@gnu.org> 2013-07-17 Antonio Diaz Diaz <antonio@gnu.org>
* Version 1.5-pre2 released. * Version 1.5-pre2 released.
@ -6,7 +12,6 @@
2013-05-13 Antonio Diaz Diaz <antonio@gnu.org> 2013-05-13 Antonio Diaz Diaz <antonio@gnu.org>
* Version 1.5-pre1 released. * Version 1.5-pre1 released.
* Decompression time has been reduced by 1%.
* main.c (show_header): Show header version if verbosity >= 4. * main.c (show_header): Show header version if verbosity >= 4.
* 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.

4
NEWS
View file

@ -2,9 +2,7 @@ Changes in version 1.5:
Clzip now shows the progress of compression at verbosity level 2 (-vv). Clzip now shows the progress of compression at verbosity level 2 (-vv).
Decompression time has been reduced by 1%. Decompressing and testing no more show file version.
File version is now shown only if verbosity >= 4.
Option "-n, --threads" is now accepted and ignored for compatibility Option "-n, --threads" is now accepted and ignored for compatibility
with plzip. with plzip.

12
README
View file

@ -6,10 +6,6 @@ compresses more than bzip2, which makes it well suited for software
distribution and data archiving. Clzip is a clean implementation of the distribution and data archiving. Clzip is a clean implementation of the
LZMA algorithm. LZMA algorithm.
Clzip uses the same well-defined exit status values used by lzip and
bzip2, which makes it safer when used in pipes or scripts than
compressors returning ambiguous warning values, like gzip.
Clzip uses the lzip file format; the files produced by clzip are fully Clzip uses the lzip file format; the files produced by clzip are fully
compatible with lzip-1.4 or newer, and can be rescued with lziprecover. compatible with lzip-1.4 or newer, and can be rescued with lziprecover.
Clzip is in fact a C language version of lzip, intended for embedded Clzip is in fact a C language version of lzip, intended for embedded
@ -34,6 +30,10 @@ lziprecover program. Lziprecover makes lzip files resistant to bit-flip
recovery capabilities, including error-checked merging of damaged copies recovery capabilities, including error-checked merging of damaged copies
of a file. of a file.
Clzip uses the same well-defined exit status values used by lzip and
bzip2, which makes it safer when used in pipes or scripts than
compressors returning ambiguous warning values, like gzip.
Clzip replaces every file given in the command line with a compressed Clzip replaces every file given in the command line with a compressed
version of itself, with the name "original_name.lz". Each compressed version of itself, with the name "original_name.lz". Each compressed
file has the same modification date, permissions, and, when possible, file has the same modification date, permissions, and, when possible,
@ -59,7 +59,7 @@ multivolume compressed tar archives.
Clzip is able to compress and decompress streams of unlimited size by Clzip is able to compress and decompress streams of unlimited size by
automatically creating multi-member output. The members so created are automatically creating multi-member output. The members so created are
large (about 2^60 bytes each). large, about 64 PiB each.
Clzip will automatically use the smallest possible dictionary size Clzip will automatically use the smallest possible dictionary size
without exceeding the given limit. Keep in mind that the decompression without exceeding the given limit. Keep in mind that the decompression
@ -78,7 +78,7 @@ The ideas embodied in clzip are due to (at least) the following people:
Abraham Lempel and Jacob Ziv (for the LZ algorithm), Andrey Markov (for Abraham Lempel and Jacob Ziv (for the LZ algorithm), Andrey Markov (for
the definition of Markov chains), G.N.N. Martin (for the definition of the definition of Markov chains), G.N.N. Martin (for the definition of
range encoding), Igor Pavlov (for putting all the above together in range encoding), Igor Pavlov (for putting all the above together in
LZMA), and Julian Seward (for bzip2's CLI and the idea of unzcrash). LZMA), and Julian Seward (for bzip2's CLI).
Copyright (C) 2010, 2011, 2012, 2013 Antonio Diaz Diaz. Copyright (C) 2010, 2011, 2012, 2013 Antonio Diaz Diaz.

2
configure vendored
View file

@ -6,7 +6,7 @@
# to copy, distribute and modify it. # to copy, distribute and modify it.
pkgname=clzip pkgname=clzip
pkgversion=1.5-pre2 pkgversion=1.5-rc1
progname=clzip progname=clzip
srctrigger=doc/${pkgname}.texinfo srctrigger=doc/${pkgname}.texinfo

View file

@ -225,13 +225,7 @@ int LZd_decode_member( struct LZ_decoder * const decoder,
int len; int len;
if( Rd_decode_bit( rdec, &decoder->bm_rep[state] ) == 1 ) /* 2nd bit */ if( Rd_decode_bit( rdec, &decoder->bm_rep[state] ) == 1 ) /* 2nd bit */
{ {
if( Rd_decode_bit( rdec, &decoder->bm_rep0[state] ) == 0 ) /* 3rd bit */ if( Rd_decode_bit( rdec, &decoder->bm_rep0[state] ) == 1 ) /* 3rd bit */
{
if( Rd_decode_bit( rdec, &decoder->bm_len[state][pos_state] ) == 0 ) /* 4th bit */
{ state = St_set_short_rep( state );
LZd_put_byte( decoder, LZd_get_byte( decoder, rep0 ) ); continue; }
}
else
{ {
unsigned distance; unsigned distance;
if( Rd_decode_bit( rdec, &decoder->bm_rep1[state] ) == 0 ) /* 4th bit */ if( Rd_decode_bit( rdec, &decoder->bm_rep1[state] ) == 0 ) /* 4th bit */
@ -247,6 +241,12 @@ int LZd_decode_member( struct LZ_decoder * const decoder,
rep1 = rep0; rep1 = rep0;
rep0 = distance; rep0 = distance;
} }
else
{
if( Rd_decode_bit( rdec, &decoder->bm_len[state][pos_state] ) == 0 ) /* 4th bit */
{ state = St_set_short_rep( state );
LZd_put_byte( decoder, LZd_get_byte( decoder, rep0 ) ); continue; }
}
state = St_set_rep( state ); state = St_set_rep( state );
len = min_match_len + Rd_decode_len( rdec, &decoder->rep_len_model, pos_state ); len = min_match_len + Rd_decode_len( rdec, &decoder->rep_len_model, pos_state );
} }

View file

@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1. .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
.TH CLZIP "1" "July 2013" "Clzip 1.5-pre2" "User Commands" .TH CLZIP "1" "August 2013" "Clzip 1.5-rc1" "User Commands"
.SH NAME .SH NAME
Clzip \- reduces the size of files Clzip \- reduces the size of files
.SH SYNOPSIS .SH SYNOPSIS
@ -70,7 +70,8 @@ Ki = KiB = 2^10 = 1024, M = 10^6, Mi = 2^20, G = 10^9, Gi = 2^30, etc...
The bidimensional parameter space of LZMA can't be mapped to a linear The bidimensional parameter space of LZMA can't be mapped to a linear
scale optimal for all files. If your files are large, very repetitive, scale optimal for all files. If your files are large, very repetitive,
etc, you may need to use the \fB\-\-match\-length\fR and \fB\-\-dictionary\-size\fR etc, you may need to use the \fB\-\-match\-length\fR and \fB\-\-dictionary\-size\fR
options directly to achieve optimal performance. options directly to achieve optimal performance. For example, \fB\-9m64\fR
usually compresses executables more (and faster) than \fB\-9\fR.
.PP .PP
Exit status: 0 for a normal exit, 1 for environmental problems (file Exit status: 0 for a normal exit, 1 for environmental problems (file
not found, invalid flags, I/O errors, etc), 2 to indicate a corrupt or not found, invalid flags, I/O errors, etc), 2 to indicate a corrupt or

View file

@ -12,7 +12,7 @@ File: clzip.info, Node: Top, Next: Introduction, Up: (dir)
Clzip Manual Clzip Manual
************ ************
This manual is for Clzip (version 1.5-pre2, 17 July 2013). This manual is for Clzip (version 1.5-rc1, 1 August 2013).
* Menu: * Menu:
@ -42,10 +42,6 @@ compresses more than bzip2, which makes it well suited for software
distribution and data archiving. Clzip is a clean implementation of the distribution and data archiving. Clzip is a clean implementation of the
LZMA algorithm. LZMA algorithm.
Clzip uses the same well-defined exit status values used by lzip and
bzip2, which makes it safer when used in pipes or scripts than
compressors returning ambiguous warning values, like gzip.
Clzip uses the lzip file format; the files produced by clzip are Clzip uses the lzip file format; the files produced by clzip are
fully compatible with lzip-1.4 or newer, and can be rescued with fully compatible with lzip-1.4 or newer, and can be rescued with
lziprecover. Clzip is in fact a C language version of lzip, intended lziprecover. Clzip is in fact a C language version of lzip, intended
@ -70,6 +66,10 @@ lziprecover program. Lziprecover makes lzip files resistant to bit-flip
recovery capabilities, including error-checked merging of damaged copies recovery capabilities, including error-checked merging of damaged copies
of a file. of a file.
Clzip uses the same well-defined exit status values used by lzip and
bzip2, which makes it safer when used in pipes or scripts than
compressors returning ambiguous warning values, like gzip.
Clzip replaces every file given in the command line with a compressed Clzip replaces every file given in the command line with a compressed
version of itself, with the name "original_name.lz". Each compressed version of itself, with the name "original_name.lz". Each compressed
file has the same modification date, permissions, and, when possible, file has the same modification date, permissions, and, when possible,
@ -95,7 +95,7 @@ multivolume compressed tar archives.
Clzip is able to compress and decompress streams of unlimited size by Clzip is able to compress and decompress streams of unlimited size by
automatically creating multi-member output. The members so created are automatically creating multi-member output. The members so created are
large (about 2^60 bytes each). large, about 64 PiB each.
The amount of memory required for compression is about 1 or 2 times The amount of memory required for compression is about 1 or 2 times
the dictionary size limit (1 if input file size is less than dictionary the dictionary size limit (1 if input file size is less than dictionary
@ -174,7 +174,7 @@ The ideas embodied in clzip are due to (at least) the following people:
Abraham Lempel and Jacob Ziv (for the LZ algorithm), Andrey Markov (for Abraham Lempel and Jacob Ziv (for the LZ algorithm), Andrey Markov (for
the definition of Markov chains), G.N.N. Martin (for the definition of the definition of Markov chains), G.N.N. Martin (for the definition of
range encoding), Igor Pavlov (for putting all the above together in range encoding), Igor Pavlov (for putting all the above together in
LZMA), and Julian Seward (for bzip2's CLI and the idea of unzcrash). LZMA), and Julian Seward (for bzip2's CLI).
 
File: clzip.info, Node: Invoking clzip, Next: File format, Prev: Algorithm, Up: Top File: clzip.info, Node: Invoking clzip, Next: File format, Prev: Algorithm, Up: Top
@ -198,10 +198,9 @@ The format for running clzip is:
`-b BYTES' `-b BYTES'
`--member-size=BYTES' `--member-size=BYTES'
Produce a multi-member file and set the member size limit to BYTES. Set the member size limit to BYTES. A small member size may
Minimum member size limit is 100kB. Small member size may degrade degrade compression ratio, so use it only when needed. Valid values
compression ratio, so use it only when needed. The default is to range from 100 kB to 64 PiB. Defaults to 64 PiB.
produce single-member files.
`-c' `-c'
`--stdout' `--stdout'
@ -250,8 +249,8 @@ The format for running clzip is:
`-s BYTES' `-s BYTES'
`--dictionary-size=BYTES' `--dictionary-size=BYTES'
Set the dictionary size limit in bytes. Valid values range from Set the dictionary size limit in bytes. Valid values range from 4
4KiB to 512MiB. Clzip will use the smallest possible dictionary KiB to 512 MiB. Clzip will use the smallest possible dictionary
size for each member without exceeding this limit. Note that size for each member without exceeding this limit. Note that
dictionary sizes are quantized. If the specified size does not dictionary sizes are quantized. If the specified size does not
match one of the valid sizes, it will be rounded upwards by adding match one of the valid sizes, it will be rounded upwards by adding
@ -267,9 +266,9 @@ The format for running clzip is:
Split the compressed output into several volume files with names Split the compressed output into several volume files with names
`original_name00001.lz', `original_name00002.lz', etc, and set the `original_name00001.lz', `original_name00002.lz', etc, and set the
volume size limit to BYTES. Each volume is a complete, maybe volume size limit to BYTES. Each volume is a complete, maybe
multi-member, lzip file. Minimum volume size limit is 100kB. Small multi-member, lzip file. A small volume size may degrade
volume size may degrade compression ratio, so use it only when compression ratio, so use it only when needed. Valid values range
needed. from 100 kB to 4 EiB.
`-t' `-t'
`--test' `--test'
@ -296,7 +295,8 @@ The format for running clzip is:
linear scale optimal for all files. If your files are large, very linear scale optimal for all files. If your files are large, very
repetitive, etc, you may need to use the `--match-length' and repetitive, etc, you may need to use the `--match-length' and
`--dictionary-size' options directly to achieve optimal `--dictionary-size' options directly to achieve optimal
performance. performance. For example, `-9m64' usually compresses executables
more (and faster) than `-9'.
Level Dictionary size Match length limit Level Dictionary size Match length limit
-1 1 MiB 5 bytes -1 1 MiB 5 bytes
@ -314,7 +314,6 @@ The format for running clzip is:
Aliases for GNU gzip compatibility. Aliases for GNU gzip compatibility.
Numbers given as arguments to options may be followed by a multiplier Numbers given as arguments to options may be followed by a multiplier
and an optional `B' for "byte". and an optional `B' for "byte".
@ -373,7 +372,7 @@ additional information before, between, or after them.
`ID string' `ID string'
A four byte string, identifying the lzip format, with the value A four byte string, identifying the lzip format, with the value
"LZIP". "LZIP" (0x4C, 0x5A, 0x49, 0x50).
`VN (version number, 1 byte)' `VN (version number, 1 byte)'
Just in case something needs to be modified in the future. 1 for Just in case something needs to be modified in the future. 1 for
@ -388,7 +387,7 @@ additional information before, between, or after them.
Bits 4-0 contain the base 2 logarithm of the base size (12 to 29). Bits 4-0 contain the base 2 logarithm of the base size (12 to 29).
Bits 7-5 contain the number of wedges (0 to 7) to substract from Bits 7-5 contain the number of wedges (0 to 7) to substract from
the base size to obtain the dictionary size. the base size to obtain the dictionary size.
Example: 0xD3 = (2^19 - 6 * 2^15) = (512KiB - 6 * 32KiB) = 320KiB Example: 0xD3 = 2^19 - 6 * 2^15 = 512 KiB - 6 * 32 KiB = 320 KiB
Valid values for dictionary size range from 4 KiB to 512 MiB. Valid values for dictionary size range from 4 KiB to 512 MiB.
`Lzma stream' `Lzma stream'
@ -476,7 +475,7 @@ Example 9: Extract a multivolume compressed tar archive.
clzip -cd volume_name*.lz | tar -xf - clzip -cd volume_name*.lz | tar -xf -
Example 10: Create a multivolume compressed backup of a big database Example 10: Create a multivolume compressed backup of a large database
file with a volume size of 650 MB, where each volume is a multi-member file with a volume size of 650 MB, where each volume is a multi-member
file with a member size of 32 MiB. file with a member size of 32 MiB.
@ -522,12 +521,12 @@ Concept index
Tag Table: Tag Table:
Node: Top212 Node: Top212
Node: Introduction914 Node: Introduction914
Node: Algorithm5096 Node: Algorithm5091
Node: Invoking clzip7620 Node: Invoking clzip7590
Node: File format13179 Node: File format13187
Node: Examples15658 Node: Examples15692
Node: Problems17619 Node: Problems17660
Node: Concept index18145 Node: Concept index18186
 
End Tag Table End Tag Table

View file

@ -6,8 +6,8 @@
@finalout @finalout
@c %**end of header @c %**end of header
@set UPDATED 17 July 2013 @set UPDATED 1 August 2013
@set VERSION 1.5-pre2 @set VERSION 1.5-rc1
@dircategory Data Compression @dircategory Data Compression
@direntry @direntry
@ -61,10 +61,6 @@ compresses more than bzip2, which makes it well suited for software
distribution and data archiving. Clzip is a clean implementation of the distribution and data archiving. Clzip is a clean implementation of the
LZMA algorithm. LZMA algorithm.
Clzip uses the same well-defined exit status values used by lzip and
bzip2, which makes it safer when used in pipes or scripts than
compressors returning ambiguous warning values, like gzip.
Clzip uses the lzip file format; the files produced by clzip are fully Clzip uses the lzip file format; the files produced by clzip are fully
compatible with lzip-1.4 or newer, and can be rescued with lziprecover. compatible with lzip-1.4 or newer, and can be rescued with lziprecover.
Clzip is in fact a C language version of lzip, intended for embedded Clzip is in fact a C language version of lzip, intended for embedded
@ -89,6 +85,10 @@ lziprecover program. Lziprecover makes lzip files resistant to bit-flip
recovery capabilities, including error-checked merging of damaged copies recovery capabilities, including error-checked merging of damaged copies
of a file. of a file.
Clzip uses the same well-defined exit status values used by lzip and
bzip2, which makes it safer when used in pipes or scripts than
compressors returning ambiguous warning values, like gzip.
Clzip replaces every file given in the command line with a compressed Clzip replaces every file given in the command line with a compressed
version of itself, with the name "original_name.lz". Each compressed version of itself, with the name "original_name.lz". Each compressed
file has the same modification date, permissions, and, when possible, file has the same modification date, permissions, and, when possible,
@ -114,7 +114,7 @@ multivolume compressed tar archives.
Clzip is able to compress and decompress streams of unlimited size by Clzip is able to compress and decompress streams of unlimited size by
automatically creating multi-member output. The members so created are automatically creating multi-member output. The members so created are
large (about 2^60 bytes each). large, about 64 PiB each.
The amount of memory required for compression is about 1 or 2 times the The amount of memory required for compression is about 1 or 2 times the
dictionary size limit (1 if input file size is less than dictionary size dictionary size limit (1 if input file size is less than dictionary size
@ -195,7 +195,7 @@ The ideas embodied in clzip are due to (at least) the following people:
Abraham Lempel and Jacob Ziv (for the LZ algorithm), Andrey Markov (for Abraham Lempel and Jacob Ziv (for the LZ algorithm), Andrey Markov (for
the definition of Markov chains), G.N.N. Martin (for the definition of the definition of Markov chains), G.N.N. Martin (for the definition of
range encoding), Igor Pavlov (for putting all the above together in range encoding), Igor Pavlov (for putting all the above together in
LZMA), and Julian Seward (for bzip2's CLI and the idea of unzcrash). LZMA), and Julian Seward (for bzip2's CLI).
@node Invoking clzip @node Invoking clzip
@ -224,10 +224,9 @@ Print the version number of clzip on the standard output and exit.
@item -b @var{bytes} @item -b @var{bytes}
@itemx --member-size=@var{bytes} @itemx --member-size=@var{bytes}
Produce a multi-member file and set the member size limit to @var{bytes}. Set the member size limit to @var{bytes}. A small member size may
Minimum member size limit is 100kB. Small member size may degrade degrade compression ratio, so use it only when needed. Valid values
compression ratio, so use it only when needed. The default is to produce range from 100 kB to 64 PiB. Defaults to 64 PiB.
single-member files.
@item -c @item -c
@itemx --stdout @itemx --stdout
@ -288,8 +287,9 @@ is affected at compression time by the choice of dictionary size limit.
Split the compressed output into several volume files with names Split the compressed output into several volume files with names
@samp{original_name00001.lz}, @samp{original_name00002.lz}, etc, and set @samp{original_name00001.lz}, @samp{original_name00002.lz}, etc, and set
the volume size limit to @var{bytes}. Each volume is a complete, maybe the volume size limit to @var{bytes}. Each volume is a complete, maybe
multi-member, lzip file. Minimum volume size limit is 100kB. Small volume multi-member, lzip file. A small volume size may degrade compression
size may degrade compression ratio, so use it only when needed. ratio, so use it only when needed. Valid values range from 100 kB to 4
EiB.
@item -t @item -t
@itemx --test @itemx --test
@ -315,7 +315,8 @@ The bidimensional parameter space of LZMA can't be mapped to a linear
scale optimal for all files. If your files are large, very repetitive, scale optimal for all files. If your files are large, very repetitive,
etc, you may need to use the @samp{--match-length} and etc, you may need to use the @samp{--match-length} and
@samp{--dictionary-size} options directly to achieve optimal @samp{--dictionary-size} options directly to achieve optimal
performance. performance. For example, @samp{-9m64} usually compresses executables
more (and faster) than @samp{-9}.
@multitable {Level} {Dictionary size} {Match length limit} @multitable {Level} {Dictionary size} {Match length limit}
@item Level @tab Dictionary size @tab Match length limit @item Level @tab Dictionary size @tab Match length limit
@ -336,7 +337,6 @@ Aliases for GNU gzip compatibility.
@end table @end table
@sp 1
Numbers given as arguments to options may be followed by a multiplier Numbers given as arguments to options may be followed by a multiplier
and an optional @samp{B} for "byte". and an optional @samp{B} for "byte".
@ -402,7 +402,8 @@ All multibyte values are stored in little endian order.
@table @samp @table @samp
@item ID string @item ID string
A four byte string, identifying the lzip format, with the value "LZIP". A four byte string, identifying the lzip format, with the value "LZIP"
(0x4C, 0x5A, 0x49, 0x50).
@item VN (version number, 1 byte) @item VN (version number, 1 byte)
Just in case something needs to be modified in the future. 1 for now. Just in case something needs to be modified in the future. 1 for now.
@ -415,7 +416,7 @@ wedges between 0 and 7. The size of a wedge is (base_size / 16).@*
Bits 4-0 contain the base 2 logarithm of the base size (12 to 29).@* Bits 4-0 contain the base 2 logarithm of the base size (12 to 29).@*
Bits 7-5 contain the number of wedges (0 to 7) to substract from the Bits 7-5 contain the number of wedges (0 to 7) to substract from the
base size to obtain the dictionary size.@* base size to obtain the dictionary size.@*
Example: 0xD3 = (2^19 - 6 * 2^15) = (512KiB - 6 * 32KiB) = 320KiB@* Example: 0xD3 = 2^19 - 6 * 2^15 = 512 KiB - 6 * 32 KiB = 320 KiB@*
Valid values for dictionary size range from 4 KiB to 512 MiB. Valid values for dictionary size range from 4 KiB to 512 MiB.
@item Lzma stream @item Lzma stream
@ -530,7 +531,7 @@ clzip -cd volume_name*.lz | tar -xf -
@sp 1 @sp 1
@noindent @noindent
Example 10: Create a multivolume compressed backup of a big database Example 10: Create a multivolume compressed backup of a large database
file with a volume size of 650 MB, where each volume is a multi-member file with a volume size of 650 MB, where each volume is a multi-member
file with a member size of 32 MiB. file with a member size of 32 MiB.

View file

@ -73,7 +73,8 @@ bool Mf_init( struct Matchfinder * const mf,
const int dict_size, const int match_len_limit, const int ifd ) const int dict_size, const int match_len_limit, const int ifd )
{ {
const int buffer_size_limit = ( 2 * dict_size ) + before_size + after_size; const int buffer_size_limit = ( 2 * dict_size ) + before_size + after_size;
int i, size; unsigned size;
int i;
mf->partial_data_pos = 0; mf->partial_data_pos = 0;
mf->match_len_limit = match_len_limit; mf->match_len_limit = match_len_limit;
@ -105,7 +106,7 @@ bool Mf_init( struct Matchfinder * const mf,
mf->pos_limit = mf->buffer_size; mf->pos_limit = mf->buffer_size;
if( !mf->at_stream_end ) mf->pos_limit -= after_size; if( !mf->at_stream_end ) mf->pos_limit -= after_size;
size = 1 << max( 16, real_bits( mf->dictionary_size - 1 ) - 2 ); size = 1 << max( 16, real_bits( mf->dictionary_size - 1 ) - 2 );
if( mf->dictionary_size > 1 << 26 ) if( mf->dictionary_size > 1 << 26 ) /* 64 MiB */
size >>= 1; size >>= 1;
mf->key4_mask = size - 1; mf->key4_mask = size - 1;
size += num_prev_positions2; size += num_prev_positions2;
@ -113,7 +114,8 @@ bool Mf_init( struct Matchfinder * const mf,
mf->num_prev_positions = size; mf->num_prev_positions = size;
size += ( 2 * ( mf->dictionary_size + 1 ) ); size += ( 2 * ( mf->dictionary_size + 1 ) );
mf->prev_positions = (int32_t *)malloc( size * sizeof (int32_t) ); if( size * sizeof (int32_t) <= size ) mf->prev_positions = 0;
else mf->prev_positions = (int32_t *)malloc( size * sizeof (int32_t) );
if( !mf->prev_positions ) { free( mf->buffer ); return false; } if( !mf->prev_positions ) { free( mf->buffer ); return false; }
mf->prev_pos_tree = mf->prev_positions + mf->num_prev_positions; mf->prev_pos_tree = mf->prev_positions + mf->num_prev_positions;
for( i = 0; i < mf->num_prev_positions; ++i ) mf->prev_positions[i] = -1; for( i = 0; i < mf->num_prev_positions; ++i ) mf->prev_positions[i] = -1;

6
lzip.h
View file

@ -202,15 +202,15 @@ static inline unsigned Fh_get_dictionary_size( const File_header data )
return sz; return sz;
} }
static inline bool Fh_set_dictionary_size( File_header data, const int sz ) static inline bool Fh_set_dictionary_size( File_header data, const unsigned sz )
{ {
if( sz >= min_dictionary_size && sz <= max_dictionary_size ) if( sz >= min_dictionary_size && sz <= max_dictionary_size )
{ {
data[5] = real_bits( sz - 1 ); data[5] = real_bits( sz - 1 );
if( sz > min_dictionary_size ) if( sz > min_dictionary_size )
{ {
const int base_size = 1 << data[5]; const unsigned base_size = 1 << data[5];
const int wedge = base_size / 16; const unsigned wedge = base_size / 16;
int i; int i;
for( i = 7; i >= 1; --i ) for( i = 7; i >= 1; --i )
if( base_size - ( i * wedge ) >= sz ) if( base_size - ( i * wedge ) >= sz )

19
main.c
View file

@ -84,8 +84,6 @@ struct Lzma_options
}; };
enum Mode { m_compress, m_decompress, m_test }; enum Mode { m_compress, m_decompress, m_test };
const unsigned long long max_member_size = 0x1000000000000000ULL;
const unsigned long long max_volume_size = 0x7FFFFFFFFFFFFFFFULL;
char * output_filename = 0; char * output_filename = 0;
int outfd = -1; int outfd = -1;
@ -126,7 +124,8 @@ static void show_help( void )
"The bidimensional parameter space of LZMA can't be mapped to a linear\n" "The bidimensional parameter space of LZMA can't be mapped to a linear\n"
"scale optimal for all files. If your files are large, very repetitive,\n" "scale optimal for all files. If your files are large, very repetitive,\n"
"etc, you may need to use the --match-length and --dictionary-size\n" "etc, you may need to use the --match-length and --dictionary-size\n"
"options directly to achieve optimal performance.\n" "options directly to achieve optimal performance. For example, -9m64\n"
"usually compresses executables more (and faster) than -9.\n"
"\nExit status: 0 for a normal exit, 1 for environmental problems (file\n" "\nExit status: 0 for a normal exit, 1 for environmental problems (file\n"
"not found, invalid flags, I/O errors, etc), 2 to indicate a corrupt or\n" "not found, invalid flags, I/O errors, etc), 2 to indicate a corrupt or\n"
"invalid input file, 3 for an internal consistency error (eg, bug) which\n" "invalid input file, 3 for an internal consistency error (eg, bug) which\n"
@ -146,7 +145,7 @@ static void show_version( void )
} }
void show_header( const File_header header ) static void show_header( const File_header header )
{ {
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" };
@ -159,8 +158,6 @@ void show_header( const File_header header )
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 = ""; }
if( verbosity >= 4 )
fprintf( stderr, "version %d, ", Fh_version( header ) );
fprintf( stderr, "dictionary size %s%4u %sB. ", np, num, p ); fprintf( stderr, "dictionary size %s%4u %sB. ", np, num, p );
} }
@ -273,12 +270,13 @@ static int open_instream( const char * const name, struct stat * const in_statsp
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 ) && ( !to_stdout || !can_read ) ) ) const bool no_ofile = to_stdout || program_mode == m_test;
if( i != 0 || ( !S_ISREG( mode ) && ( !can_read || !no_ofile ) ) )
{ {
if( verbosity >= 0 ) if( verbosity >= 0 )
fprintf( stderr, "%s: Input file '%s' is not a regular file%s.\n", fprintf( stderr, "%s: Input file '%s' is not a regular file%s.\n",
program_name, name, program_name, name,
( can_read && !to_stdout ) ? ( can_read && !no_ofile ) ?
" and '--stdout' was not specified" : "" ); " and '--stdout' was not specified" : "" );
close( infd ); close( infd );
infd = -1; infd = -1;
@ -532,7 +530,8 @@ static int decompress( const int infd, struct Pretty_print * const pp,
if( Rd_finished( &rdec ) ) /* End Of File */ if( Rd_finished( &rdec ) ) /* End Of File */
{ {
if( first_member ) if( first_member )
{ Pp_show_msg( pp, "Error reading member header" ); retval = 1; } { Pp_show_msg( pp, "File ends unexpectedly at member header" );
retval = 2; }
break; break;
} }
if( !Fh_verify_magic( header ) ) if( !Fh_verify_magic( header ) )
@ -695,6 +694,8 @@ 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 unsigned long long max_member_size = 0x0100000000000000ULL;
const unsigned long long max_volume_size = 0x4000000000000000ULL;
unsigned long long member_size = max_member_size; unsigned long long member_size = max_member_size;
unsigned long long volume_size = 0; unsigned long long volume_size = 0;
const char * input_filename = ""; const char * input_filename = "";

View file

@ -35,6 +35,18 @@ if [ $? = 1 ] ; then printf . ; else fail=1 ; printf - ; fi
if [ $? = 1 ] ; then printf . ; else fail=1 ; printf - ; fi if [ $? = 1 ] ; then printf . ; else fail=1 ; printf - ; fi
"${LZIP}" -cqm274 in > /dev/null "${LZIP}" -cqm274 in > /dev/null
if [ $? = 1 ] ; then printf . ; else fail=1 ; printf - ; fi if [ $? = 1 ] ; then printf . ; else fail=1 ; printf - ; fi
"${LZIP}" -tq in
if [ $? = 2 ] ; then printf . ; else fail=1 ; printf - ; fi
"${LZIP}" -tq < in
if [ $? = 2 ] ; then printf . ; else fail=1 ; printf - ; fi
"${LZIP}" -cdq in
if [ $? = 2 ] ; then printf . ; else fail=1 ; printf - ; fi
"${LZIP}" -cdq < in
if [ $? = 2 ] ; then printf . ; else fail=1 ; printf - ; fi
dd if="${in_lz}" bs=1 count=6 2> /dev/null | "${LZIP}" -tq
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
dd if="${in_lz}" bs=1 count=20 2> /dev/null | "${LZIP}" -tq
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
"${LZIP}" -t "${in_lz}" || fail=1 "${LZIP}" -t "${in_lz}" || fail=1
"${LZIP}" -cd "${in_lz}" > copy || fail=1 "${LZIP}" -cd "${in_lz}" > copy || fail=1