diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 05:10:03 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 05:10:03 +0000 |
commit | df409dd4fc7a0bfe48c40fab6dca07bcba160676 (patch) | |
tree | f3923adc44f5704dd8ccf5b6b7422487eea3e886 | |
parent | Adding upstream version 1.7. (diff) | |
download | lunzip-df409dd4fc7a0bfe48c40fab6dca07bcba160676.tar.xz lunzip-df409dd4fc7a0bfe48c40fab6dca07bcba160676.zip |
Adding upstream version 1.8~pre1.upstream/1.8_pre1
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | Makefile.in | 2 | ||||
-rw-r--r-- | NEWS | 9 | ||||
-rw-r--r-- | README | 4 | ||||
-rwxr-xr-x | configure | 6 | ||||
-rw-r--r-- | decoder.c | 19 | ||||
-rw-r--r-- | decoder.h | 2 | ||||
-rw-r--r-- | doc/lunzip.1 | 6 | ||||
-rw-r--r-- | lzip.h | 2 | ||||
-rw-r--r-- | main.c | 60 | ||||
-rwxr-xr-x | testsuite/check.sh | 4 |
11 files changed, 67 insertions, 53 deletions
@@ -1,3 +1,9 @@ +2015-07-07 Antonio Diaz Diaz <antonio@gnu.org> + + * Version 1.8-pre1 released. + * main.c (main): With '-u', verify that output file is regular. + * Error messages synced with lzip-1.17. + 2015-05-27 Antonio Diaz Diaz <antonio@gnu.org> * Version 1.7 released. diff --git a/Makefile.in b/Makefile.in index 1ae3c91..1ec2aaa 100644 --- a/Makefile.in +++ b/Makefile.in @@ -42,7 +42,7 @@ $(VPATH)/doc/$(pkgname).info : $(VPATH)/doc/$(pkgname).texi man : $(VPATH)/doc/$(progname).1 $(VPATH)/doc/$(progname).1 : $(progname) - help2man -n 'decompressor for lzip files' -o $@ --no-info ./$(progname) + help2man -n 'decompressor for the lzip format' -o $@ --no-info ./$(progname) Makefile : $(VPATH)/configure $(VPATH)/Makefile.in ./config.status @@ -1,6 +1,7 @@ -Changes in version 1.7: +Changes in version 1.8: -Minor changes have been made. +Lunzip now verifies that the output file is regular when "low memory" +mode is requested. -The targets "install-compress", "install-strip-compress", and -"install-man-compress" have been added to the Makefile. +Some error messages have been adjusted to be identical to those of +lzip-1.17. @@ -1,6 +1,6 @@ Description -Lunzip is a decompressor for lzip files. It is written in C and its +Lunzip is a decompressor for the lzip format. It is written in C and its small size makes it well suited for embedded devices or software installers that need to decompress files but do not need compression capabilities. Lunzip is fully compatible with lzip-1.4 or newer. @@ -45,7 +45,7 @@ the more accesses to disk are needed and the slower the decompression is. This "low memory" mode only works when decompressing to a regular file and is intended for systems without enough memory (RAM + swap) to keep the whole dictionary at once. It has been tested on a laptop with a -486 processor and 4MiB of RAM. +486 processor and 4 MiB of RAM. The amount of memory required by lunzip to decompress a file is about 46 kB larger than the dictionary size used to compress that file, unless @@ -1,12 +1,12 @@ #! /bin/sh -# configure script for Lunzip - Decompressor for lzip files +# configure script for Lunzip - Decompressor for the lzip format # Copyright (C) 2010-2015 Antonio Diaz Diaz. # # This configure script is free software: you have unlimited permission # to copy, distribute and modify it. pkgname=lunzip -pkgversion=1.7 +pkgversion=1.8-pre1 progname=lunzip srctrigger=doc/${progname}.1 @@ -164,7 +164,7 @@ echo "CFLAGS = ${CFLAGS}" echo "LDFLAGS = ${LDFLAGS}" rm -f Makefile cat > Makefile << EOF -# Makefile for Lunzip - Decompressor for lzip files +# Makefile for Lunzip - Decompressor for the lzip format # Copyright (C) 2010-2015 Antonio Diaz Diaz. # This file was generated automatically by configure. Do not edit. # @@ -1,4 +1,4 @@ -/* Lunzip - Decompressor for lzip files +/* Lunzip - Decompressor for the lzip format Copyright (C) 2010-2015 Antonio Diaz Diaz. This program is free software: you can redistribute it and/or modify @@ -38,11 +38,10 @@ 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 ); @@ -162,7 +161,7 @@ static bool LZd_verify_trailer( struct LZ_decoder * const d, if( verbosity >= 0 ) { Pp_show_msg( pp, 0 ); - fprintf( stderr, "CRC mismatch; trailer says %08X, data CRC is %08X.\n", + fprintf( stderr, "CRC mismatch; trailer says %08X, data CRC is %08X\n", trailer_crc, LZd_crc( d ) ); } } @@ -173,7 +172,7 @@ static bool LZd_verify_trailer( struct LZ_decoder * const d, if( verbosity >= 0 ) { Pp_show_msg( pp, 0 ); - fprintf( stderr, "Data size mismatch; trailer says %llu, data size is %llu (0x%llX).\n", + fprintf( stderr, "Data size mismatch; trailer says %llu, data size is %llu (0x%llX)\n", trailer_data_size, LZd_data_position( d ), LZd_data_position( d ) ); } } @@ -184,7 +183,7 @@ static bool LZd_verify_trailer( struct LZ_decoder * const d, if( verbosity >= 0 ) { Pp_show_msg( pp, 0 ); - fprintf( stderr, "Member size mismatch; trailer says %llu, member size is %llu (0x%llX).\n", + fprintf( stderr, "Member size mismatch; trailer says %llu, member size is %llu (0x%llX)\n", trailer_member_size, member_size, member_size ); } } @@ -237,7 +236,7 @@ int LZd_decode_member( struct LZ_decoder * const d, LZd_peek( d, rep0 ) ) ); } } - else + else /* match or repeated match */ { int len; if( Rd_decode_bit( rdec, &d->bm_rep[state] ) != 0 ) /* 2nd bit */ @@ -267,7 +266,7 @@ int LZd_decode_member( struct LZ_decoder * const d, state = St_set_rep( state ); len = min_match_len + Rd_decode_len( rdec, &d->rep_len_model, pos_state ); } - else + else /* match */ { int dis_slot; const unsigned rep0_saved = rep0; @@ -301,7 +300,7 @@ int LZd_decode_member( struct LZ_decoder * const d, if( verbosity >= 0 ) { Pp_show_msg( pp, 0 ); - fprintf( stderr, "Unsupported marker code '%d'.\n", len ); + fprintf( stderr, "Unsupported marker code '%d'\n", len ); } return 4; } @@ -1,4 +1,4 @@ -/* Lunzip - Decompressor for lzip files +/* Lunzip - Decompressor for the lzip format Copyright (C) 2010-2015 Antonio Diaz Diaz. This program is free software: you can redistribute it and/or modify diff --git a/doc/lunzip.1 b/doc/lunzip.1 index 9e37eea..7a35eb5 100644 --- a/doc/lunzip.1 +++ b/doc/lunzip.1 @@ -1,12 +1,12 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.46.1. -.TH LUNZIP "1" "May 2015" "lunzip 1.7" "User Commands" +.TH LUNZIP "1" "July 2015" "lunzip 1.8-pre1" "User Commands" .SH NAME -lunzip \- decompressor for lzip files +lunzip \- decompressor for the lzip format .SH SYNOPSIS .B lunzip [\fI\,options\/\fR] [\fI\,files\/\fR] .SH DESCRIPTION -Lunzip is a decompressor for lzip files. It is written in C and its +Lunzip is a decompressor for the lzip format. It is written in C and its small size makes it well suited for embedded devices or software installers that need to decompress files but do not need compression capabilities. Lunzip is fully compatible with lzip\-1.4 or newer. @@ -1,4 +1,4 @@ -/* Lunzip - Decompressor for lzip files +/* Lunzip - Decompressor for the lzip format Copyright (C) 2010-2015 Antonio Diaz Diaz. This program is free software: you can redistribute it and/or modify @@ -1,4 +1,4 @@ -/* Lunzip - Decompressor for lzip files +/* Lunzip - Decompressor for the lzip format Copyright (C) 2010-2015 Antonio Diaz Diaz. This program is free software: you can redistribute it and/or modify @@ -84,7 +84,7 @@ bool delete_output_on_interrupt = false; static void show_help( void ) { - printf( "Lunzip is a decompressor for lzip files. It is written in C and its\n" + printf( "Lunzip is a decompressor for the lzip format. It is written in C and its\n" "small size makes it well suited for embedded devices or software\n" "installers that need to decompress files but do not need compression\n" "capabilities. Lunzip is fully compatible with lzip-1.4 or newer.\n" @@ -95,8 +95,8 @@ static void show_help( void ) "file as dictionary for distances beyond the buffer size. Of course, the\n" "smaller the output buffer size used in relation to the dictionary size,\n" "the more accesses to disk are needed and the slower the decompression is.\n" - "This 'low memory' mode only works when decompressing to a regular file.\n" ); - printf( "\nUsage: %s [options] [files]\n", invocation_name ); + "This 'low memory' mode only works when decompressing to a regular file.\n" + "\nUsage: %s [options] [files]\n", invocation_name ); printf( "\nOptions:\n" " -h, --help display this help and exit\n" " -V, --version output version information and exit\n" @@ -242,7 +242,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 @@ -258,7 +258,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; } @@ -301,7 +301,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 ); } @@ -318,7 +318,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 ); @@ -371,8 +371,8 @@ static void close_and_set_permissions( const struct stat * const in_statsp ) } -static int decompress( const int buffer_size, const int infd, - struct Pretty_print * const pp, const bool testing ) +static int decompress( const int infd, struct Pretty_print * const pp, + const int buffer_size, const bool testing ) { unsigned long long partial_file_pos = 0; struct Range_decoder rdec; @@ -435,20 +435,17 @@ static int decompress( const int buffer_size, const int infd, if( verbosity >= 0 && result <= 2 ) { Pp_show_msg( pp, 0 ); - if( result == 2 ) - fprintf( stderr, "File ends unexpectedly at pos %llu.\n", - partial_file_pos ); - else - fprintf( stderr, "Decoder error at pos %llu.\n", partial_file_pos ); + fprintf( stderr, "%s at pos %llu\n", ( result == 2 ) ? + "File ends unexpectedly" : "Decoder error", partial_file_pos ); } retval = 2; break; } if( verbosity >= 2 ) - { fprintf( stderr, testing ? "ok\n" : "done\n" ); Pp_reset( pp ); } + { fputs( testing ? "ok\n" : "done\n", stderr ); Pp_reset( pp ); } } Rd_free( &rdec ); if( verbosity == 1 && retval == 0 ) - fprintf( stderr, testing ? "ok\n" : "done\n" ); + fputs( testing ? "ok\n" : "done\n", stderr ); return retval; } @@ -476,8 +473,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", @@ -581,15 +578,26 @@ int main( const int argc, const char * const argv[] ) if( buffer_size < max_dictionary_size ) { + struct stat st; + bool from_stdin = false; if( to_stdout || testing ) { show_error( "'--buffer-size' is incompatible with '--stdout' and '--test'.", 0, false ); return 1; } - if( !default_output_filename[0] ) - for( i = 0; i < num_filenames; ++i ) - if( !filenames[i][0] || strcmp( filenames[i], "-" ) == 0 ) - { show_error( "Output file must be specified when decompressing from stdin with a\n" - " reduced buffer size.", 0, false ); - return 1; } + for( i = 0; i < num_filenames; ++i ) + if( !filenames[i][0] || strcmp( filenames[i], "-" ) == 0 ) + { from_stdin = true; break; } + if( from_stdin && !default_output_filename[0] ) + { show_error( "Output file must be specified when decompressing from stdin with a\n" + " reduced buffer size.", 0, false ); return 1; } + if( from_stdin && default_output_filename[0] && + stat( default_output_filename, &st ) == 0 && !S_ISREG( st.st_mode ) ) + { + if( verbosity >= 0 ) + fprintf( stderr, "%s: Output file '%s' is not a regular file,\n" + " and 'low memory' mode has been requested.\n", + program_name, default_output_filename ); + return 1; + } } if( !to_stdout && !testing && @@ -661,7 +669,7 @@ int main( const int argc, const char * const argv[] ) delete_output_on_interrupt = true; in_statsp = input_filename[0] ? &in_stats : 0; Pp_set_name( &pp, input_filename ); - tmp = decompress( buffer_size, infd, &pp, testing ); + tmp = decompress( infd, &pp, buffer_size, testing ); if( tmp > retval ) retval = tmp; if( tmp && !testing ) cleanup_and_fail( retval ); diff --git a/testsuite/check.sh b/testsuite/check.sh index bdf4fdc..f647d6c 100755 --- a/testsuite/check.sh +++ b/testsuite/check.sh @@ -1,5 +1,5 @@ #! /bin/sh -# check script for Lunzip - Decompressor for lzip files +# check script for Lunzip - Decompressor for the lzip format # Copyright (C) 2010-2015 Antonio Diaz Diaz. # # This script is free software: you have unlimited permission @@ -75,7 +75,6 @@ printf . cat in in > in2 || framework_failure cat "${in_lz}" "${in_lz}" > copy2.lz || framework_failure "${LZIP}" -t copy2.lz || fail=1 -printf . "${LZIP}" -cd copy2.lz > copy2 || fail=1 cmp in2 copy2 || fail=1 printf . @@ -86,6 +85,7 @@ printf "to be overwritten" > copy2 || framework_failure cmp in2 copy2 || fail=1 printf . +rm -f copy for i in 12 4096 4Ki 29 512KiB ; do printf "to be overwritten" > copy || framework_failure "${LZIP}" -df -u$i -o copy < "${in_lz}" || fail=1 |