summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 13:49:25 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 13:49:25 +0000
commita9c3fa13430e0d6d6a0b61e70a8cfb1b15e84d4e (patch)
tree28dd368a0fc8339a5b027678819407ff0a41333e /main.c
parentAdding debian version 1.4-3. (diff)
downloadlzlib-a9c3fa13430e0d6d6a0b61e70a8cfb1b15e84d4e.tar.xz
lzlib-a9c3fa13430e0d6d6a0b61e70a8cfb1b15e84d4e.zip
Merging upstream version 1.5~rc1.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'main.c')
-rw-r--r--main.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/main.c b/main.c
index 6732b13..cb38b88 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* Minilzip - A test program for the lzlib library
+/* Minilzip - Test program for the lzlib library
Copyright (C) 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify
@@ -147,7 +147,7 @@ static void Pp_show_msg( struct Pretty_print * const pp, const char * const msg
static void show_help( void )
{
- printf( "%s - A test program for the lzlib library.\n", Program_name );
+ printf( "%s - Test program for the lzlib library.\n", Program_name );
printf( "\nUsage: %s [options] [files]\n", invocation_name );
printf( "\nOptions:\n"
" -h, --help display this help and exit\n"
@@ -196,7 +196,7 @@ static void show_version( void )
}
-void show_header( struct LZ_Decoder * const decoder )
+static void show_header( struct LZ_Decoder * const decoder )
{
const char * const prefix[8] =
{ "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi" };
@@ -209,8 +209,6 @@ void show_header( struct LZ_Decoder * const decoder )
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, ", LZ_decompress_member_version( decoder ) );
fprintf( stderr, "dictionary size %s%4u %sB. ", np, num, p );
}
@@ -323,12 +321,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;
@@ -468,7 +467,7 @@ static void close_and_set_permissions( const struct stat * const in_statsp )
/* 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 )
+static int readblock( const int fd, uint8_t * const buf, const int size )
{
int rest = size;
errno = 0;
@@ -487,7 +486,7 @@ int readblock( const int fd, uint8_t * const buf, const int 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 )
+static int writeblock( const int fd, const uint8_t * const buf, const int size )
{
int rest = size;
errno = 0;
@@ -714,8 +713,8 @@ int do_decompress( struct LZ_Decoder * const decoder, const int infd,
if( lz_errno == LZ_header_error || ( first_member && out_size == 0 ) )
{
if( !first_member ) break; /* trailing garbage */
- Pp_show_msg( pp, "Error reading member header" );
- return 1;
+ Pp_show_msg( pp, "Bad magic number (file not in lzip format)" );
+ return 2;
}
if( lz_errno == LZ_mem_error )
{