summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AUTHORS2
-rw-r--r--ChangeLog7
-rw-r--r--NEWS4
-rw-r--r--README12
-rwxr-xr-xconfigure2
-rw-r--r--decoder.c14
-rw-r--r--doc/clzip.17
-rw-r--r--doc/clzip.info65
-rw-r--r--doc/clzip.texinfo55
-rw-r--r--encoder.c8
-rw-r--r--lzip.h6
-rw-r--r--main.c25
-rwxr-xr-xtestsuite/check.sh12
13 files changed, 119 insertions, 100 deletions
diff --git a/AUTHORS b/AUTHORS
index fa8757e..3b49e65 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -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
the definition of Markov chains), G.N.N. Martin (for the definition of
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).
diff --git a/ChangeLog b/ChangeLog
index 753fc4e..3755bc2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* Version 1.5-pre2 released.
@@ -6,7 +12,6 @@
2013-05-13 Antonio Diaz Diaz <antonio@gnu.org>
* Version 1.5-pre1 released.
- * Decompression time has been reduced by 1%.
* main.c (show_header): Show header version if verbosity >= 4.
* Ignore option '-n, --threads' for compatibility with plzip.
* configure: Options now accept a separate argument.
diff --git a/NEWS b/NEWS
index 25a7276..d17d735 100644
--- a/NEWS
+++ b/NEWS
@@ -2,9 +2,7 @@ Changes in version 1.5:
Clzip now shows the progress of compression at verbosity level 2 (-vv).
-Decompression time has been reduced by 1%.
-
-File version is now shown only if verbosity >= 4.
+Decompressing and testing no more show file version.
Option "-n, --threads" is now accepted and ignored for compatibility
with plzip.
diff --git a/README b/README
index 0043c8c..b9066ec 100644
--- a/README
+++ b/README
@@ -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
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
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
@@ -34,6 +30,10 @@ lziprecover program. Lziprecover makes lzip files resistant to bit-flip
recovery capabilities, including error-checked merging of damaged copies
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
version of itself, with the name "original_name.lz". Each compressed
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
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
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
the definition of Markov chains), G.N.N. Martin (for the definition of
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.
diff --git a/configure b/configure
index 846ca8b..dc3023b 100755
--- a/configure
+++ b/configure
@@ -6,7 +6,7 @@
# to copy, distribute and modify it.
pkgname=clzip
-pkgversion=1.5-pre2
+pkgversion=1.5-rc1
progname=clzip
srctrigger=doc/${pkgname}.texinfo
diff --git a/decoder.c b/decoder.c
index d1df32f..9c31677 100644
--- a/decoder.c
+++ b/decoder.c
@@ -225,13 +225,7 @@ int LZd_decode_member( struct LZ_decoder * const decoder,
int len;
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_len[state][pos_state] ) == 0 ) /* 4th bit */
- { state = St_set_short_rep( state );
- LZd_put_byte( decoder, LZd_get_byte( decoder, rep0 ) ); continue; }
- }
- else
+ if( Rd_decode_bit( rdec, &decoder->bm_rep0[state] ) == 1 ) /* 3rd bit */
{
unsigned distance;
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;
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 );
len = min_match_len + Rd_decode_len( rdec, &decoder->rep_len_model, pos_state );
}
diff --git a/doc/clzip.1 b/doc/clzip.1
index 6ad560c..5c1bd8c 100644
--- a/doc/clzip.1
+++ b/doc/clzip.1
@@ -1,5 +1,5 @@
.\" 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
Clzip \- reduces the size of files
.SH SYNOPSIS
@@ -43,7 +43,7 @@ if reading stdin, place the output into <file>
suppress all messages
.TP
\fB\-s\fR, \fB\-\-dictionary\-size=\fR<bytes>
-set dictionary size limit in bytes [8MiB]
+set dictionary size limit in bytes [8 MiB]
.TP
\fB\-S\fR, \fB\-\-volume\-size=\fR<bytes>
set volume size limit in bytes
@@ -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
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
-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
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
diff --git a/doc/clzip.info b/doc/clzip.info
index 263affa..f7a9f4a 100644
--- a/doc/clzip.info
+++ b/doc/clzip.info
@@ -12,7 +12,7 @@ File: clzip.info, Node: Top, Next: Introduction, Up: (dir)
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:
@@ -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
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 compatible with lzip-1.4 or newer, and can be rescued with
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
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
version of itself, with the name "original_name.lz". Each compressed
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
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 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
the definition of Markov chains), G.N.N. Martin (for the definition of
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
@@ -198,10 +198,9 @@ The format for running clzip is:
`-b BYTES'
`--member-size=BYTES'
- Produce a multi-member file and set the member size limit to BYTES.
- Minimum member size limit is 100kB. Small member size may degrade
- compression ratio, so use it only when needed. The default is to
- produce single-member files.
+ Set the member size limit to BYTES. A small member size may
+ degrade compression ratio, so use it only when needed. Valid values
+ range from 100 kB to 64 PiB. Defaults to 64 PiB.
`-c'
`--stdout'
@@ -250,8 +249,8 @@ The format for running clzip is:
`-s BYTES'
`--dictionary-size=BYTES'
- Set the dictionary size limit in bytes. Valid values range from
- 4KiB to 512MiB. Clzip will use the smallest possible dictionary
+ Set the dictionary size limit in bytes. Valid values range from 4
+ KiB to 512 MiB. Clzip will use the smallest possible dictionary
size for each member without exceeding this limit. Note that
dictionary sizes are quantized. If the specified size does not
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
`original_name00001.lz', `original_name00002.lz', etc, and set the
volume size limit to BYTES. Each volume is a complete, maybe
- multi-member, lzip file. Minimum volume size limit is 100kB. Small
- volume size may degrade compression ratio, so use it only when
- needed.
+ multi-member, lzip file. A small volume size may degrade
+ compression ratio, so use it only when needed. Valid values range
+ from 100 kB to 4 EiB.
`-t'
`--test'
@@ -296,7 +295,8 @@ The format for running clzip is:
linear scale optimal for all files. If your files are large, very
repetitive, etc, you may need to use the `--match-length' and
`--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
-1 1 MiB 5 bytes
@@ -314,7 +314,6 @@ The format for running clzip is:
Aliases for GNU gzip compatibility.
-
Numbers given as arguments to options may be followed by a multiplier
and an optional `B' for "byte".
@@ -373,7 +372,7 @@ additional information before, between, or after them.
`ID string'
A four byte string, identifying the lzip format, with the value
- "LZIP".
+ "LZIP" (0x4C, 0x5A, 0x49, 0x50).
`VN (version number, 1 byte)'
Just in case something needs to be modified in the future. 1 for
@@ -388,8 +387,8 @@ additional information before, between, or after them.
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 base size to obtain the dictionary size.
- Example: 0xD3 = (2^19 - 6 * 2^15) = (512KiB - 6 * 32KiB) = 320KiB
- Valid values for dictionary size range from 4KiB to 512MiB.
+ 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.
`Lzma stream'
The lzma stream, finished by an end of stream marker. Uses default
@@ -430,7 +429,7 @@ and show the compression ratio.
Example 2: Like example 1 but the created `file.lz' is multi-member
-with a member size of 1MiB. The compression ratio is not shown.
+with a member size of 1 MiB. The compression ratio is not shown.
clzip -b 1MiB file
@@ -453,7 +452,7 @@ Example 5: Compress a whole floppy in /dev/fd0 and send the output to
clzip -c /dev/fd0 > file.lz
-Example 6: Decompress `file.lz' partially until 10KiB of decompressed
+Example 6: Decompress `file.lz' partially until 10 KiB of decompressed
data are produced.
clzip -cd file.lz | dd bs=1024 count=10
@@ -466,7 +465,7 @@ to decompressed byte 15000 (5000 bytes are produced).
Example 8: Create a multivolume compressed tar archive with a volume
-size of 1440KiB.
+size of 1440 KiB.
tar -c some_directory | clzip -S 1440KiB -o volume_name
@@ -476,9 +475,9 @@ Example 9: Extract a multivolume compressed tar archive.
clzip -cd volume_name*.lz | tar -xf -
-Example 10: Create a multivolume compressed backup of a big database
-file with a volume size of 650MB, where each volume is a multi-member
-file with a member size of 32MiB.
+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 member size of 32 MiB.
clzip -b 32MiB -S 650MB big_db
@@ -522,12 +521,12 @@ Concept index
Tag Table:
Node: Top212
Node: Introduction914
-Node: Algorithm5096
-Node: Invoking clzip7620
-Node: File format13179
-Node: Examples15658
-Node: Problems17619
-Node: Concept index18145
+Node: Algorithm5091
+Node: Invoking clzip7590
+Node: File format13187
+Node: Examples15692
+Node: Problems17660
+Node: Concept index18186

End Tag Table
diff --git a/doc/clzip.texinfo b/doc/clzip.texinfo
index 49d0761..ac684be 100644
--- a/doc/clzip.texinfo
+++ b/doc/clzip.texinfo
@@ -6,8 +6,8 @@
@finalout
@c %**end of header
-@set UPDATED 17 July 2013
-@set VERSION 1.5-pre2
+@set UPDATED 1 August 2013
+@set VERSION 1.5-rc1
@dircategory Data Compression
@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
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
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
@@ -89,6 +85,10 @@ lziprecover program. Lziprecover makes lzip files resistant to bit-flip
recovery capabilities, including error-checked merging of damaged copies
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
version of itself, with the name "original_name.lz". Each compressed
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
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
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
the definition of Markov chains), G.N.N. Martin (for the definition of
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
@@ -224,10 +224,9 @@ Print the version number of clzip on the standard output and exit.
@item -b @var{bytes}
@itemx --member-size=@var{bytes}
-Produce a multi-member file and set the member size limit to @var{bytes}.
-Minimum member size limit is 100kB. Small member size may degrade
-compression ratio, so use it only when needed. The default is to produce
-single-member files.
+Set the member size limit to @var{bytes}. A small member size may
+degrade compression ratio, so use it only when needed. Valid values
+range from 100 kB to 64 PiB. Defaults to 64 PiB.
@item -c
@itemx --stdout
@@ -273,8 +272,8 @@ Quiet operation. Suppress all messages.
@item -s @var{bytes}
@itemx --dictionary-size=@var{bytes}
-Set the dictionary size limit in bytes. Valid values range from 4KiB to
-512MiB. Clzip will use the smallest possible dictionary size for each
+Set the dictionary size limit in bytes. Valid values range from 4 KiB to
+512 MiB. Clzip will use the smallest possible dictionary size for each
member without exceeding this limit. Note that dictionary sizes are
quantized. If the specified size does not match one of the valid sizes,
it will be rounded upwards by adding up to (@var{bytes} / 16) to it.
@@ -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
@samp{original_name00001.lz}, @samp{original_name00002.lz}, etc, and set
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
-size may degrade compression ratio, so use it only when needed.
+multi-member, lzip file. A small volume size may degrade compression
+ratio, so use it only when needed. Valid values range from 100 kB to 4
+EiB.
@item -t
@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,
etc, you may need to use the @samp{--match-length} and
@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}
@item Level @tab Dictionary size @tab Match length limit
@@ -336,7 +337,6 @@ Aliases for GNU gzip compatibility.
@end table
-@sp 1
Numbers given as arguments to options may be followed by a multiplier
and an optional @samp{B} for "byte".
@@ -402,7 +402,8 @@ All multibyte values are stored in little endian order.
@table @samp
@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)
Just in case something needs to be modified in the future. 1 for now.
@@ -415,8 +416,8 @@ 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 7-5 contain the number of wedges (0 to 7) to substract from the
base size to obtain the dictionary size.@*
-Example: 0xD3 = (2^19 - 6 * 2^15) = (512KiB - 6 * 32KiB) = 320KiB@*
-Valid values for dictionary size range from 4KiB to 512MiB.
+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.
@item Lzma stream
The lzma stream, finished by an end of stream marker. Uses default values
@@ -459,7 +460,7 @@ clzip -v file
@sp 1
@noindent
Example 2: Like example 1 but the created @samp{file.lz} is multi-member
-with a member size of 1MiB. The compression ratio is not shown.
+with a member size of 1 MiB. The compression ratio is not shown.
@example
clzip -b 1MiB file
@@ -495,7 +496,7 @@ clzip -c /dev/fd0 > file.lz
@sp 1
@noindent
-Example 6: Decompress @samp{file.lz} partially until 10KiB of
+Example 6: Decompress @samp{file.lz} partially until 10 KiB of
decompressed data are produced.
@example
@@ -514,7 +515,7 @@ clzip -cd file.lz | dd bs=1000 skip=10 count=5
@sp 1
@noindent
Example 8: Create a multivolume compressed tar archive with a volume
-size of 1440KiB.
+size of 1440 KiB.
@example
tar -c some_directory | clzip -S 1440KiB -o volume_name
@@ -530,9 +531,9 @@ clzip -cd volume_name*.lz | tar -xf -
@sp 1
@noindent
-Example 10: Create a multivolume compressed backup of a big database
-file with a volume size of 650MB, where each volume is a multi-member
-file with a member size of 32MiB.
+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 member size of 32 MiB.
@example
clzip -b 32MiB -S 650MB big_db
diff --git a/encoder.c b/encoder.c
index 312c569..66358cb 100644
--- a/encoder.c
+++ b/encoder.c
@@ -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 buffer_size_limit = ( 2 * dict_size ) + before_size + after_size;
- int i, size;
+ unsigned size;
+ int i;
mf->partial_data_pos = 0;
mf->match_len_limit = match_len_limit;
@@ -105,7 +106,7 @@ bool Mf_init( struct Matchfinder * const mf,
mf->pos_limit = mf->buffer_size;
if( !mf->at_stream_end ) mf->pos_limit -= after_size;
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;
mf->key4_mask = size - 1;
size += num_prev_positions2;
@@ -113,7 +114,8 @@ bool Mf_init( struct Matchfinder * const mf,
mf->num_prev_positions = size;
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; }
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;
diff --git a/lzip.h b/lzip.h
index 6141d5d..6f11a75 100644
--- a/lzip.h
+++ b/lzip.h
@@ -202,15 +202,15 @@ static inline unsigned Fh_get_dictionary_size( const File_header data )
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 )
{
data[5] = real_bits( sz - 1 );
if( sz > min_dictionary_size )
{
- const int base_size = 1 << data[5];
- const int wedge = base_size / 16;
+ const unsigned base_size = 1 << data[5];
+ const unsigned wedge = base_size / 16;
int i;
for( i = 7; i >= 1; --i )
if( base_size - ( i * wedge ) >= sz )
diff --git a/main.c b/main.c
index c1057b5..ee9a751 100644
--- a/main.c
+++ b/main.c
@@ -79,13 +79,11 @@ struct { const char * from; const char * to; } const known_extensions[] = {
struct Lzma_options
{
- int dictionary_size; /* 4KiB..512MiB */
- int match_len_limit; /* 5..273 */
+ int dictionary_size; /* 4 KiB .. 512 MiB */
+ int match_len_limit; /* 5 .. 273 */
};
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;
int outfd = -1;
@@ -112,7 +110,7 @@ static void show_help( void )
" -m, --match-length=<bytes> set match length limit in bytes [36]\n"
" -o, --output=<file> if reading stdin, place the output into <file>\n"
" -q, --quiet suppress all messages\n"
- " -s, --dictionary-size=<bytes> set dictionary size limit in bytes [8MiB]\n"
+ " -s, --dictionary-size=<bytes> set dictionary size limit in bytes [8 MiB]\n"
" -S, --volume-size=<bytes> set volume size limit in bytes\n"
" -t, --test test compressed file integrity\n"
" -v, --verbose be verbose (a 2nd -v gives more)\n"
@@ -126,7 +124,8 @@ static void show_help( void )
"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"
"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"
"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"
@@ -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] =
{ "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 )
{ num /= factor; if( num % factor != 0 ) exact = false;
p = prefix[i]; np = ""; }
- if( verbosity >= 4 )
- fprintf( stderr, "version %d, ", Fh_version( header ) );
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 &&
( S_ISBLK( mode ) || S_ISCHR( 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 )
fprintf( stderr, "%s: Input file '%s' is not a regular file%s.\n",
program_name, name,
- ( can_read && !to_stdout ) ?
+ ( can_read && !no_ofile ) ?
" and '--stdout' was not specified" : "" );
close( infd );
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( 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;
}
if( !Fh_verify_magic( header ) )
@@ -695,6 +694,8 @@ int main( const int argc, const char * const argv[] )
{ 3 << 23, 132 }, /* -8 */
{ 1 << 25, 273 } }; /* -9 */
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 volume_size = 0;
const char * input_filename = "";
diff --git a/testsuite/check.sh b/testsuite/check.sh
index 980c3da..53c52a3 100755
--- a/testsuite/check.sh
+++ b/testsuite/check.sh
@@ -35,6 +35,18 @@ if [ $? = 1 ] ; then printf . ; else fail=1 ; printf - ; fi
if [ $? = 1 ] ; then printf . ; else fail=1 ; printf - ; fi
"${LZIP}" -cqm274 in > /dev/null
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}" -cd "${in_lz}" > copy || fail=1