summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-06 11:32:20 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-06 11:32:20 +0000
commit3d23a83fd1e0732d9103ceaf8fd30ac3aadf7035 (patch)
treef02d32497d7c5b913ef32a2270c498ed47a987d1
parentAdding upstream version 1.1. (diff)
downloadclzip-3d23a83fd1e0732d9103ceaf8fd30ac3aadf7035.tar.xz
clzip-3d23a83fd1e0732d9103ceaf8fd30ac3aadf7035.zip
Adding upstream version 1.2.upstream/1.2
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
-rw-r--r--ChangeLog14
-rw-r--r--Makefile.in1
-rw-r--r--NEWS28
-rw-r--r--carg_parser.c7
-rw-r--r--carg_parser.h4
-rw-r--r--clzip.h3
-rwxr-xr-xconfigure2
-rw-r--r--decoder.c47
-rw-r--r--decoder.h2
-rw-r--r--doc/clzip.15
-rw-r--r--doc/clzip.info35
-rw-r--r--doc/clzip.texinfo22
-rw-r--r--encoder.c48
-rw-r--r--encoder.h29
-rw-r--r--main.c60
-rwxr-xr-xtestsuite/check.sh15
-rw-r--r--testsuite/test_sync.lzbin0 -> 11658 bytes
17 files changed, 197 insertions, 125 deletions
diff --git a/ChangeLog b/ChangeLog
index f17cb75..3a8a0a1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2011-05-18 Antonio Diaz Diaz <ant_diaz@teleline.es>
+
+ * Version 1.2 released.
+ * main.c: Added new option `-F, --recompress'.
+ * main.c (decompress): Print only one status line for each
+ multimember file when only one `-v' is specified.
+ * encoder.h (Lee_update_prices): Update high length symbol prices
+ independently of the value of `pos_state'. This gives better
+ compression for large values of `--match-length' without being
+ slower.
+ * encoder.h encoder.c: Optimize pair price calculations. This
+ reduces compression time for large values of `--match-length'
+ by up to 6%.
+
2011-01-11 Antonio Diaz Diaz <ant_diaz@teleline.es>
* Version 1.1 released.
diff --git a/Makefile.in b/Makefile.in
index 15dc4e7..ec79b02 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -95,6 +95,7 @@ dist : doc
$(DISTNAME)/doc/$(pkgname).texinfo \
$(DISTNAME)/testsuite/check.sh \
$(DISTNAME)/testsuite/test.txt \
+ $(DISTNAME)/testsuite/test_sync.lz \
$(DISTNAME)/testsuite/test_v[01].lz \
$(DISTNAME)/*.h \
$(DISTNAME)/*.c
diff --git a/NEWS b/NEWS
index e74d0b8..6a4e828 100644
--- a/NEWS
+++ b/NEWS
@@ -1,24 +1,10 @@
-Changes in version 1.1:
+Changes in version 1.2:
-Code has been converted to "C89 + long long". A C99 compiler is no more
-needed.
+The option "-F, --recompress", which forces recompression of files whose
+name already has the ".lz" or ".tlz" suffix, has been added.
-A warning about fchown's return value being ignored has been fixed.
+Print only one status line for each multimember file when only one "-v"
+is specified.
-"clzip -tvvvv" now shows file compression ratio.
-
-Match length limit set by options -1 to -8 has been reduced to extend
-range of use towards gzip. Lower numbers now compress less but faster.
-(-1 now takes 43% less time for only 20% larger compressed size).
-
-(Note that 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 --match-length and
---dictionary-size options directly to achieve optimal performance).
-
-Compression of option -9 has been slightly increased.
-
-Do not show the message "and `--stdout' was not specified" for file
-types that can't be read (directories, etc).
-
-Some new examples have been added to the manual.
+For large values of "--match-length", compression ratio has been
+slightly increased and compression time has been reduced by up to 6%.
diff --git a/carg_parser.c b/carg_parser.c
index ff14a87..52c8658 100644
--- a/carg_parser.c
+++ b/carg_parser.c
@@ -1,5 +1,5 @@
-/* Arg_parser - A POSIX/GNU command line argument parser. (C version)
- Copyright (C) 2006, 2007, 2008, 2009, 2010 Antonio Diaz Diaz.
+/* Arg_parser - POSIX/GNU command line argument parser. (C version)
+ Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Antonio Diaz Diaz.
This library is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -45,7 +45,8 @@ static char push_back_record( struct Arg_parser * const ap,
{
const int len = strlen( argument );
struct ap_Record *p;
- void * tmp = ap_resize_buffer( ap->data, ( ap->data_size + 1 ) * sizeof (struct ap_Record) );
+ void * tmp = ap_resize_buffer( ap->data,
+ ( ap->data_size + 1 ) * sizeof (struct ap_Record) );
if( !tmp ) return 0;
ap->data = (struct ap_Record *)tmp;
p = &(ap->data[ap->data_size]);
diff --git a/carg_parser.h b/carg_parser.h
index 4dccb5f..0f61c12 100644
--- a/carg_parser.h
+++ b/carg_parser.h
@@ -1,5 +1,5 @@
-/* Arg_parser - A POSIX/GNU command line argument parser. (C version)
- Copyright (C) 2006, 2007, 2008, 2009, 2010 Antonio Diaz Diaz.
+/* Arg_parser - POSIX/GNU command line argument parser. (C version)
+ Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Antonio Diaz Diaz.
This library is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/clzip.h b/clzip.h
index 3a7fc4a..b534d66 100644
--- a/clzip.h
+++ b/clzip.h
@@ -56,6 +56,7 @@ static inline void St_set_short_rep( State * const st )
*st = next[*st];
}
+
enum {
min_dictionary_bits = 12,
min_dictionary_size = 1 << min_dictionary_bits,
@@ -277,5 +278,7 @@ static inline void Ft_set_member_size( File_trailer data, long long sz )
void cleanup_and_fail( const int retval );
void show_error( const char * const msg, const int errcode, const bool help );
void internal_error( const char * const msg );
+
+/* defined in decoder.c */
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 );
diff --git a/configure b/configure
index 9364735..c6401de 100755
--- a/configure
+++ b/configure
@@ -8,7 +8,7 @@
args=
no_create=
pkgname=clzip
-pkgversion=1.1
+pkgversion=1.2
progname=clzip
srctrigger=clzip.h
diff --git a/decoder.c b/decoder.c
index 454b5f6..caaaa2f 100644
--- a/decoder.c
+++ b/decoder.c
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "clzip.h"
#include "decoder.h"
@@ -30,6 +31,46 @@
CRC32 crc32;
+
+/* Returns the number of bytes really read.
+ If (returned value < size) and (errno == 0), means EOF was reached.
+*/
+int readblock( const int fd, uint8_t * const buf, const int size )
+ {
+ int rest = size;
+ while( true )
+ {
+ int n;
+ errno = 0;
+ if( rest <= 0 ) break;
+ n = read( fd, buf + size - rest, rest );
+ if( n > 0 ) rest -= n;
+ else if( n == 0 ) break;
+ else if( errno != EINTR && errno != EAGAIN ) break;
+ }
+ return ( rest > 0 ) ? size - rest : size;
+ }
+
+
+/* Returns the number of bytes really written.
+ If (returned value < size), it is always an error.
+*/
+int writeblock( const int fd, const uint8_t * const buf, const int size )
+ {
+ int rest = size;
+ while( true )
+ {
+ int n;
+ errno = 0;
+ if( rest <= 0 ) break;
+ n = write( fd, buf + size - rest, rest );
+ if( n > 0 ) rest -= n;
+ else if( errno && errno != EINTR && errno != EAGAIN ) break;
+ }
+ return ( rest > 0 ) ? size - rest : size;
+ }
+
+
bool Rd_read_block( struct Range_decoder * const rdec )
{
if( !rdec->at_stream_end )
@@ -53,7 +94,7 @@ void LZd_flush_data( struct LZ_decoder * const decoder )
CRC32_update_buf( &decoder->crc_, decoder->buffer + decoder->stream_pos, size );
if( decoder->outfd >= 0 &&
writeblock( decoder->outfd, decoder->buffer + decoder->stream_pos, size ) != size )
- { show_error( "write error", errno, false ); cleanup_and_fail( 1 ); }
+ { show_error( "Write error", errno, false ); cleanup_and_fail( 1 ); }
if( decoder->pos >= decoder->buffer_size )
{ decoder->partial_data_pos += decoder->pos; decoder->pos = 0; }
decoder->stream_pos = decoder->pos;
@@ -124,12 +165,12 @@ bool LZd_verify_trailer( struct LZ_decoder * const decoder,
Ft_get_member_size( trailer ), member_size, member_size );
}
}
- if( !error && pp->verbosity >= 4 && LZd_data_position( decoder ) > 0 && member_size > 0 )
+ if( !error && pp->verbosity >= 3 && LZd_data_position( decoder ) > 0 && member_size > 0 )
fprintf( stderr, "%6.3f:1, %6.3f bits/byte, %5.2f%% saved. ",
(double)LZd_data_position( decoder ) / member_size,
( 8.0 * member_size ) / LZd_data_position( decoder ),
100.0 * ( 1.0 - ( (double)member_size / LZd_data_position( decoder ) ) ) );
- if( !error && pp->verbosity >= 3 )
+ if( !error && pp->verbosity >= 4 )
fprintf( stderr, "data CRC %08X, data size %9lld, member size %8lld. ",
(unsigned int)Ft_get_data_crc( trailer ),
Ft_get_data_size( trailer ), Ft_get_member_size( trailer ) );
diff --git a/decoder.h b/decoder.h
index bef12c9..f109c54 100644
--- a/decoder.h
+++ b/decoder.h
@@ -65,7 +65,7 @@ static inline void Rd_reset_member_position( struct Range_decoder * const rdec )
static inline uint8_t Rd_get_byte( struct Range_decoder * const rdec )
{
- if( Rd_finished( rdec ) ) return 0;
+ if( Rd_finished( rdec ) ) return 0x55; /* make code != 0 */
return rdec->buffer[rdec->pos++];
}
diff --git a/doc/clzip.1 b/doc/clzip.1
index fa126e6..1b2cac8 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" "January 2011" "Clzip 1.1" "User Commands"
+.TH CLZIP "1" "May 2011" "Clzip 1.2" "User Commands"
.SH NAME
Clzip \- reduces the size of files
.SH SYNOPSIS
@@ -27,6 +27,9 @@ decompress
\fB\-f\fR, \fB\-\-force\fR
overwrite existing output files
.TP
+\fB\-F\fR, \fB\-\-recompress\fR
+force recompression of compressed files
+.TP
\fB\-k\fR, \fB\-\-keep\fR
keep (don't delete) input files
.TP
diff --git a/doc/clzip.info b/doc/clzip.info
index 861aac7..3551973 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.1, 11 January 2011).
+This manual is for Clzip (version 1.2, 18 May 2011).
* Menu:
@@ -207,6 +207,11 @@ The format for running clzip is:
`--force'
Force overwrite of output file.
+`-F'
+`--recompress'
+ Force recompression of files whose name already has the `.lz' or
+ `.tlz' suffix.
+
`-k'
`--keep'
Keep (don't delete) input files during compression or
@@ -238,7 +243,8 @@ The format for running clzip is:
4KiB to 512MiB. 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.
+ match one of the valid sizes, it will be rounded upwards by adding
+ up to (SIZE / 16) to it.
For maximum compression you should use a dictionary size limit as
large as possible, but keep in mind that the decompression memory
@@ -263,8 +269,11 @@ The format for running clzip is:
`-v'
`--verbose'
- Verbose mode. Show the compression ratio for each file processed.
- Further -v's increase the verbosity level.
+ Verbose mode. When compressing, show the compression ratio for
+ each file processed. When decompressing or testing, further -v's
+ (up to 4) increase the verbosity level, showing status, dictionary
+ size, compression ratio, and trailer contents (CRC, data size,
+ member size).
`-1 .. -9'
Set the compression parameters (dictionary size and match length
@@ -345,8 +354,8 @@ additional information before, between, or after them.
`VN (version number, 1 byte)'
Just in case something needs to be modified in the future. Valid
- values are 0 and 1. Version 0 files have only one member and lack
- `Member size'.
+ values are 0 and 1. Version 0 files are deprecated. They can
+ contain only one member and lack the `Member size' field.
`DS (coded dictionary size, 1 byte)'
Bits 4-0 contain the base 2 logarithm of the base dictionary size.
@@ -477,12 +486,12 @@ Concept Index

Tag Table:
Node: Top226
-Node: Introduction907
-Node: Algorithm4484
-Node: Invoking Clzip7008
-Node: File Format11949
-Node: Examples13905
-Node: Problems15674
-Node: Concept Index16200
+Node: Introduction903
+Node: Algorithm4480
+Node: Invoking Clzip7004
+Node: File Format12275
+Node: Examples14269
+Node: Problems16038
+Node: Concept Index16564

End Tag Table
diff --git a/doc/clzip.texinfo b/doc/clzip.texinfo
index 1177d8a..85396ab 100644
--- a/doc/clzip.texinfo
+++ b/doc/clzip.texinfo
@@ -5,8 +5,8 @@
@finalout
@c %**end of header
-@set UPDATED 11 January 2011
-@set VERSION 1.1
+@set UPDATED 18 May 2011
+@set VERSION 1.2
@dircategory Data Compression
@direntry
@@ -231,6 +231,11 @@ Decompress.
@itemx --force
Force overwrite of output file.
+@item -F
+@itemx --recompress
+Force recompression of files whose name already has the @samp{.lz} or
+@samp{.tlz} suffix.
+
@item -k
@itemx --keep
Keep (don't delete) input files during compression or decompression.
@@ -260,7 +265,7 @@ Set the dictionary size limit in bytes. Valid values range from 4KiB to
512MiB. 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.
+it will be rounded upwards by adding up to (@var{size} / 16) to it.
For maximum compression you should use a dictionary size limit as large
as possible, but keep in mind that the decompression memory requirement
@@ -282,8 +287,11 @@ Use it together with @samp{-v} to see information about the file.
@item -v
@itemx --verbose
-Verbose mode. Show the compression ratio for each file processed.
-Further -v's increase the verbosity level.
+Verbose mode.
+When compressing, show the compression ratio for each file processed.
+When decompressing or testing, further -v's (up to 4) increase the
+verbosity level, showing status, dictionary size, compression ratio,
+and trailer contents (CRC, data size, member size).
@item -1 .. -9
Set the compression parameters (dictionary size and match length limit)
@@ -374,8 +382,8 @@ A four byte string, identifying the lzip format, with the value "LZIP".
@item VN (version number, 1 byte)
Just in case something needs to be modified in the future. Valid values
-are 0 and 1. Version 0 files have only one member and lack @samp{Member
-size}.
+are 0 and 1. Version 0 files are deprecated. They can contain only one
+member and lack the @samp{Member size} field.
@item DS (coded dictionary size, 1 byte)
Bits 4-0 contain the base 2 logarithm of the base dictionary size.@*
diff --git a/encoder.c b/encoder.c
index 597a173..20180d7 100644
--- a/encoder.c
+++ b/encoder.c
@@ -388,23 +388,25 @@ int LZe_sequence_optimizer( struct LZ_encoder * const encoder,
return 1;
}
- {
- const int normal_match_price = match_price + price0( encoder->bm_rep[state] );
- int len = min_match_len;
if( main_len <= replens[rep_index] )
{
+ int len;
main_len = replens[rep_index];
- for( ; len <= main_len; ++len )
+ for( len = min_match_len; len <= main_len; ++len )
encoder->trials[len].price = infinite_price;
}
- else for( ; len <= main_len; ++len )
+ else
{
- encoder->trials[len].dis = encoder->match_distances[len] + num_rep_distances;
- encoder->trials[len].prev_index = 0;
- encoder->trials[len].price = normal_match_price +
- LZe_price_pair( encoder, encoder->match_distances[len], len, pos_state );
+ int len;
+ const int normal_match_price = match_price + price0( encoder->bm_rep[state] );
+ for( len = min_match_len; len <= main_len; ++len )
+ {
+ encoder->trials[len].dis = encoder->match_distances[len] + num_rep_distances;
+ encoder->trials[len].prev_index = 0;
+ encoder->trials[len].price = normal_match_price +
+ LZe_price_pair( encoder, encoder->match_distances[len], len, pos_state );
+ }
}
- }
for( rep = 0; rep < num_rep_distances; ++rep )
{
@@ -513,13 +515,31 @@ int LZe_sequence_optimizer( struct LZ_encoder * const encoder,
const int normal_match_price = match_price +
price0( encoder->bm_rep[cur_trial->state] );
int len;
+ int dis = encoder->match_distances[min_match_len];
+ int dis_state = get_dis_state( min_match_len );
+ int dis_price = infinite_price;
+
while( num_trials < cur + newlen )
encoder->trials[++num_trials].price = infinite_price;
- for( len = min_match_len; len <= newlen; ++len )
- Tr_update( &encoder->trials[cur+len], encoder->match_distances[len] + num_rep_distances,
- cur, normal_match_price +
- LZe_price_pair( encoder, encoder->match_distances[len], len, pos_state ) );
+ if( dis < modeled_distances )
+ Tr_update( &encoder->trials[cur+min_match_len], dis + num_rep_distances,
+ cur, normal_match_price + encoder->dis_prices[dis_state][dis] +
+ Lee_price( &encoder->len_encoder, min_match_len, pos_state ) );
+
+ for( len = min_match_len + 1; len <= newlen; ++len )
+ {
+ if( dis != encoder->match_distances[len] ||
+ dis_state < max_dis_states - 1 )
+ {
+ dis = encoder->match_distances[len];
+ dis_state = get_dis_state( len );
+ dis_price = LZe_price_dis( encoder, dis, dis_state );
+ }
+ Tr_update( &encoder->trials[cur+len], dis + num_rep_distances, cur,
+ normal_match_price + dis_price +
+ Lee_price( &encoder->len_encoder, len, pos_state ) );
+ }
}
}
}
diff --git a/encoder.h b/encoder.h
index daaf10b..e7a6481 100644
--- a/encoder.h
+++ b/encoder.h
@@ -393,7 +393,10 @@ static inline void Lee_update_prices( struct Len_encoder * const len_encoder,
pps[len] = tmp + price0( len_encoder->choice2 ) +
price_symbol( len_encoder->bm_mid[pos_state], len - len_low_symbols, len_mid_bits );
for( ; len < len_encoder->len_symbols; ++len )
- pps[len] = tmp + price1( len_encoder->choice2 ) +
+ /* using 4 slots per value makes "Lee_price" faster */
+ len_encoder->prices[3][len] = len_encoder->prices[2][len] =
+ len_encoder->prices[1][len] = len_encoder->prices[0][len] =
+ tmp + price1( len_encoder->choice2 ) +
price_symbol( len_encoder->bm_high, len - len_low_symbols - len_mid_symbols, len_high_bits );
len_encoder->counters[pos_state] = len_encoder->len_symbols;
}
@@ -430,7 +433,7 @@ struct Literal_encoder
Bit_model bm_literal[1<<literal_context_bits][0x300];
};
-static inline int Lie_state( const int prev_byte )
+static inline int Lie_state( const uint8_t prev_byte )
{ return ( prev_byte >> ( 8 - literal_context_bits ) ); }
static inline void Lie_init( struct Literal_encoder * const literal_encoder )
@@ -558,22 +561,24 @@ static inline int LZe_price_rep( struct LZ_encoder * const encoder, const int re
return price;
}
+static inline int LZe_price_dis( struct LZ_encoder * const encoder,
+ const int dis, const int dis_state )
+ {
+ if( dis < modeled_distances )
+ return encoder->dis_prices[dis_state][dis];
+ else
+ return encoder->dis_slot_prices[dis_state][get_slot( dis )] +
+ encoder->align_prices[dis & (dis_align_size - 1)];
+ }
+
static inline int LZe_price_pair( struct LZ_encoder * const encoder,
const int dis, const int len,
const int pos_state )
{
- const int dis_state = get_dis_state( len );
- int price;
-
if( len <= min_match_len && dis >= modeled_distances )
return infinite_price;
- price = Lee_price( &encoder->len_encoder, len, pos_state );
- if( dis < modeled_distances )
- price += encoder->dis_prices[dis_state][dis];
- else
- price += encoder->dis_slot_prices[dis_state][get_slot( dis )] +
- encoder->align_prices[dis & (dis_align_size - 1)];
- return price;
+ return Lee_price( &encoder->len_encoder, len, pos_state ) +
+ LZe_price_dis( encoder, dis, get_dis_state( len ) );
}
static inline void LZe_encode_pair( struct LZ_encoder * const encoder,
diff --git a/main.c b/main.c
index 79a32bd..f24893a 100644
--- a/main.c
+++ b/main.c
@@ -128,6 +128,7 @@ static void show_help()
printf( " -c, --stdout send output to standard output\n" );
printf( " -d, --decompress decompress\n" );
printf( " -f, --force overwrite existing output files\n" );
+ printf( " -F, --recompress force recompression of compressed files\n" );
printf( " -k, --keep keep (don't delete) input files\n" );
printf( " -m, --match-length=<n> set match length limit in bytes [36]\n" );
printf( " -o, --output=<file> if reading stdin, place the output into <file>\n" );
@@ -244,10 +245,10 @@ static int get_dict_size( const char * const arg )
static int open_instream( const char * const name, struct stat * const in_statsp,
const enum Mode program_mode, const int eindex,
- const bool force, const bool to_stdout )
+ const bool recompress, const bool to_stdout )
{
int infd = -1;
- if( program_mode == m_compress && !force && eindex >= 0 )
+ if( program_mode == m_compress && !recompress && eindex >= 0 )
{
if( verbosity >= 0 )
fprintf( stderr, "%s: Input file `%s' already has `%s' suffix.\n",
@@ -327,7 +328,7 @@ static void set_d_outname( const char * const name, const int i )
output_filename = resize_buffer( output_filename, strlen( name ) + 4 + 1 );
strcpy( output_filename, name );
strcat( output_filename, ".out" );
- if( verbosity >= 0 )
+ if( verbosity >= 1 )
fprintf( stderr, "%s: Can't guess original name for `%s' -- using `%s'.\n",
program_name, name, output_filename );
}
@@ -378,7 +379,7 @@ void cleanup_and_fail( const int retval )
fprintf( stderr, "%s: Deleting output file `%s', if it exists.\n",
program_name, output_filename );
if( outfd >= 0 ) { close( outfd ); outfd = -1; }
- if( remove( output_filename ) != 0 )
+ if( remove( output_filename ) != 0 && errno != ENOENT )
show_error( "WARNING: deletion of output file (apparently) failed.", 0, false );
}
exit( retval );
@@ -538,7 +539,7 @@ static int decompress( const int infd, struct Pretty_print * const pp,
{ Pp_show_msg( pp, "Invalid dictionary size in member header" );
retval = 2; break; }
- if( verbosity >= 1 )
+ if( verbosity >= 2 || ( verbosity == 1 && first_member ) )
{
Pp_show_msg( pp, 0 );
if( verbosity >= 2 )
@@ -564,11 +565,14 @@ static int decompress( const int infd, struct Pretty_print * const pp,
}
retval = 2; break;
}
- if( verbosity >= 1 )
+ if( verbosity >= 2 )
{ if( testing ) fprintf( stderr, "ok\n" );
else fprintf( stderr, "done\n" ); }
}
Rd_free( &rdec );
+ if( verbosity == 1 && retval == 0 )
+ { if( testing ) fprintf( stderr, "ok\n" );
+ else fprintf( stderr, "done\n" ); }
return retval;
}
@@ -654,45 +658,6 @@ void internal_error( const char * const msg )
}
-/* Returns the number of bytes really read.
- If (returned value < size) and (errno == 0), means EOF was reached.
-*/
-int readblock( const int fd, uint8_t * const buf, const int size )
- {
- int rest = size;
- while( true )
- {
- int n;
- errno = 0;
- if( rest <= 0 ) break;
- n = read( fd, buf + size - rest, rest );
- if( n > 0 ) rest -= n;
- else if( n == 0 ) break;
- else if( errno != EINTR && errno != EAGAIN ) break;
- }
- return ( rest > 0 ) ? size - rest : size;
- }
-
-
-/* Returns the number of bytes really written.
- If (returned value < size), it is always an error.
-*/
-int writeblock( const int fd, const uint8_t * const buf, const int size )
- {
- int rest = size;
- while( true )
- {
- int n;
- errno = 0;
- if( rest <= 0 ) break;
- n = write( fd, buf + size - rest, rest );
- if( n > 0 ) rest -= n;
- else if( errno && errno != EINTR && errno != EAGAIN ) break;
- }
- return ( rest > 0 ) ? size - rest : size;
- }
-
-
int main( const int argc, const char * const argv[] )
{
/* Mapping from gzip/bzip2 style 1..9 compression modes
@@ -724,6 +689,7 @@ int main( const int argc, const char * const argv[] )
bool filenames_given = false;
bool force = false;
bool keep_input_files = false;
+ bool recompress = false;
bool to_stdout = false;
struct Pretty_print pp;
@@ -744,6 +710,7 @@ int main( const int argc, const char * const argv[] )
{ 'd', "decompress", ap_no },
{ 'e', "extreme", ap_no },
{ 'f', "force", ap_no },
+ { 'F', "recompress", ap_no },
{ 'h', "help", ap_no },
{ 'k', "keep", ap_no },
{ 'm', "match-length", ap_yes },
@@ -781,6 +748,7 @@ int main( const int argc, const char * const argv[] )
case 'd': program_mode = m_decompress; break;
case 'e': break; /* ignored by now */
case 'f': force = true; break;
+ case 'F': recompress = true; break;
case 'h': show_help(); return 0;
case 'k': keep_input_files = true; break;
case 'm': encoder_options.match_len_limit =
@@ -871,7 +839,7 @@ int main( const int argc, const char * const argv[] )
const int eindex = extension_index( filenames[i] );
input_filename = filenames[i];
infd = open_instream( input_filename, &in_stats, program_mode,
- eindex, force, to_stdout );
+ eindex, recompress, to_stdout );
if( infd < 0 ) { if( retval < 1 ) retval = 1; continue; }
if( program_mode != m_test )
{
diff --git a/testsuite/check.sh b/testsuite/check.sh
index 4d1377e..50bec2e 100755
--- a/testsuite/check.sh
+++ b/testsuite/check.sh
@@ -37,6 +37,19 @@ printf .
cmp in copy || fail=1
printf .
+"${LZIP}" -t "${testdir}"/test_sync.lz || fail=1
+printf .
+"${LZIP}" -cd "${testdir}"/test_sync.lz > copy || fail=1
+cmp in copy || fail=1
+printf .
+
+"${LZIP}" -cf "${testdir}"/test_v1.lz > out 2>/dev/null
+if [ $? != 1 ] ; then fail=1 ; printf - ; else printf . ; fi
+"${LZIP}" -cF "${testdir}"/test_v1.lz > out || fail=1
+"${LZIP}" -cd out | "${LZIP}" -d > copy || fail=1
+cmp in copy || fail=1
+printf .
+
for i in s4Ki 0 1 2 3 4 5 6 7 8 9 ; do
"${LZIP}" -k -$i in || fail=1
mv -f in.lz copy.lz || fail=1
@@ -69,7 +82,7 @@ for i in s4Ki 0 1 2 3 4 5 6 7 8 9 ; do
done
"${LZIP}" -$i < in > anyothername || fail=1
-"${LZIP}" -dq anyothername || fail=1
+"${LZIP}" -d anyothername || fail=1
cmp in anyothername.out || fail=1
printf .
diff --git a/testsuite/test_sync.lz b/testsuite/test_sync.lz
new file mode 100644
index 0000000..419fa97
--- /dev/null
+++ b/testsuite/test_sync.lz
Binary files differ