summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 14:08:08 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 14:08:08 +0000
commitcffb4d6baffb84bc4f2f168ae3be7431e7a19a3e (patch)
tree52b702a077e13b87c1f94fdc7f9f9f537facc8e7 /main.c
parentAdding debian version 1.7~rc1-1. (diff)
downloadlzlib-cffb4d6baffb84bc4f2f168ae3be7431e7a19a3e.tar.xz
lzlib-cffb4d6baffb84bc4f2f168ae3be7431e7a19a3e.zip
Merging upstream version 1.7.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-rw-r--r--main.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/main.c b/main.c
index cab15b5..129ac2d 100644
--- a/main.c
+++ b/main.c
@@ -147,11 +147,10 @@ static void Pp_show_msg( struct Pretty_print * const pp, const char * const msg
{
if( pp->first_post )
{
- int i, len;
+ int i, len = pp->longest_name - strlen( pp->name );
pp->first_post = false;
fprintf( stderr, " %s: ", pp->name );
- len = pp->longest_name - strlen( pp->name );
- for( i = 0; i < len; ++i ) fprintf( stderr, " " );
+ for( i = 0; i < len; ++i ) fputc( ' ', stderr );
if( !msg ) fflush( stderr );
}
if( msg ) fprintf( stderr, "%s\n", msg );
@@ -170,7 +169,7 @@ static void show_help( void )
" -c, --stdout send output to standard output\n"
" -d, --decompress decompress\n"
" -f, --force overwrite existing output files\n"
- " -F, --recompress force recompression of compressed files\n"
+ " -F, --recompress force re-compression of compressed files\n"
" -k, --keep keep (don't delete) input files\n"
" -m, --match-length=<bytes> set match length limit in bytes [36]\n"
" -o, --output=<file> if reading stdin, place the output into <file>\n"
@@ -246,7 +245,7 @@ static unsigned long long getnum( const char * const ptr,
if( !errno && tail[0] )
{
- int factor = ( tail[1] == 'i' ) ? 1024 : 1000;
+ const int factor = ( tail[1] == 'i' ) ? 1024 : 1000;
int exponent = 0, i;
bool bad_multiplier = false;
switch( tail[0] )
@@ -296,7 +295,7 @@ static int get_dict_size( const char * const arg )
return ( 1 << bits );
dictionary_size = getnum( arg, LZ_min_dictionary_size(),
LZ_max_dictionary_size() );
- if( dictionary_size == 65535 ) ++dictionary_size;
+ if( dictionary_size == 65535 ) ++dictionary_size; /* no fast encoder */
return dictionary_size;
}
@@ -334,7 +333,7 @@ static int open_instream( const char * const name, struct stat * const in_statsp
if( infd < 0 )
{
if( verbosity >= 0 )
- fprintf( stderr, "%s: Can't open input file '%s': %s.\n",
+ fprintf( stderr, "%s: Can't open input file '%s': %s\n",
program_name, name, strerror( errno ) );
}
else
@@ -351,7 +350,7 @@ static int open_instream( const char * const name, struct stat * const in_statsp
fprintf( stderr, "%s: Input file '%s' is not a regular file%s.\n",
program_name, name,
( can_read && !no_ofile ) ?
- " and '--stdout' was not specified" : "" );
+ ",\n and '--stdout' was not specified" : "" );
close( infd );
infd = -1;
}
@@ -405,7 +404,7 @@ static void set_d_outname( const char * const name, const int i )
strcpy( output_filename, name );
strcat( output_filename, ".out" );
if( verbosity >= 1 )
- fprintf( stderr, "%s: Can't guess original name for '%s' -- using '%s'.\n",
+ fprintf( stderr, "%s: Can't guess original name for '%s' -- using '%s'\n",
program_name, name, output_filename );
}
@@ -422,7 +421,7 @@ static bool open_outstream( const bool force )
fprintf( stderr, "%s: Output file '%s' already exists, skipping.\n",
program_name, output_filename );
else
- fprintf( stderr, "%s: Can't create output file '%s': %s.\n",
+ fprintf( stderr, "%s: Can't create output file '%s': %s\n",
program_name, output_filename, strerror( errno ) );
}
return ( outfd >= 0 );
@@ -578,7 +577,7 @@ static int do_compress( struct LZ_Encoder * const encoder,
{
Pp_show_msg( pp, 0 );
if( verbosity >= 0 )
- fprintf( stderr, "%s: LZ_compress_read error: %s.\n",
+ fprintf( stderr, "%s: LZ_compress_read error: %s\n",
program_name, LZ_strerror( LZ_compress_errno( encoder ) ) );
return 1;
}
@@ -619,7 +618,7 @@ static int do_compress( struct LZ_Encoder * const encoder,
{
Pp_show_msg( pp, 0 );
if( verbosity >= 0 )
- fprintf( stderr, "%s: LZ_compress_restart_member error: %s.\n",
+ fprintf( stderr, "%s: LZ_compress_restart_member error: %s\n",
program_name, LZ_strerror( LZ_compress_errno( encoder ) ) );
return 1;
}
@@ -631,7 +630,7 @@ static int do_compress( struct LZ_Encoder * const encoder,
const unsigned long long in_size = LZ_compress_total_in_size( encoder );
const unsigned long long out_size = LZ_compress_total_out_size( encoder );
if( in_size == 0 || out_size == 0 )
- fprintf( stderr, " no data compressed.\n" );
+ fputs( " no data compressed.\n", stderr );
else
fprintf( stderr, "%6.3f:1, %6.3f bits/byte, "
"%5.2f%% saved, %llu in, %llu out.\n",
@@ -729,7 +728,7 @@ static int do_decompress( struct LZ_Decoder * const decoder, const int infd,
fprintf( stderr, "data CRC %08X, data size %9llu, member size %8llu. ",
LZ_decompress_data_crc( decoder ),
data_position, member_size );
- fprintf( stderr, testing ? "ok\n" : "done\n" );
+ fputs( testing ? "ok\n" : "done\n", stderr );
}
first_member = false; Pp_reset( pp );
}
@@ -750,10 +749,10 @@ static int do_decompress( struct LZ_Decoder * const decoder, const int infd,
{
Pp_show_msg( pp, 0 );
if( lz_errno == LZ_unexpected_eof )
- fprintf( stderr, "File ends unexpectedly at pos %llu.\n",
+ fprintf( stderr, "File ends unexpectedly at pos %llu\n",
LZ_decompress_total_in_size( decoder ) );
else
- fprintf( stderr, "Decoder error at pos %llu: %s.\n",
+ fprintf( stderr, "Decoder error at pos %llu: %s\n",
LZ_decompress_total_in_size( decoder ),
LZ_strerror( LZ_decompress_errno( decoder ) ) );
}
@@ -805,8 +804,8 @@ void show_error( const char * const msg, const int errcode, const bool help )
if( msg && msg[0] )
{
fprintf( stderr, "%s: %s", program_name, msg );
- if( errcode > 0 ) fprintf( stderr, ": %s.", strerror( errcode ) );
- fprintf( stderr, "\n" );
+ if( errcode > 0 ) fprintf( stderr, ": %s", strerror( errcode ) );
+ fputc( '\n', stderr );
}
if( help )
fprintf( stderr, "Try '%s --help' for more information.\n",