1
0
Fork 0

Merging upstream version 1.8~pre1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-17 22:21:23 +01:00
parent a83c3a9034
commit 37b8e0babb
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
11 changed files with 67 additions and 53 deletions

View file

@ -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> 2015-05-27 Antonio Diaz Diaz <antonio@gnu.org>
* Version 1.7 released. * Version 1.7 released.

View file

@ -42,7 +42,7 @@ $(VPATH)/doc/$(pkgname).info : $(VPATH)/doc/$(pkgname).texi
man : $(VPATH)/doc/$(progname).1 man : $(VPATH)/doc/$(progname).1
$(VPATH)/doc/$(progname).1 : $(progname) $(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 Makefile : $(VPATH)/configure $(VPATH)/Makefile.in
./config.status ./config.status

9
NEWS
View file

@ -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 Some error messages have been adjusted to be identical to those of
"install-man-compress" have been added to the Makefile. lzip-1.17.

2
README
View file

@ -1,6 +1,6 @@
Description 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 small size makes it well suited for embedded devices or software
installers that need to decompress files but do not need compression installers that need to decompress files but do not need compression
capabilities. Lunzip is fully compatible with lzip-1.4 or newer. capabilities. Lunzip is fully compatible with lzip-1.4 or newer.

6
configure vendored
View file

@ -1,12 +1,12 @@
#! /bin/sh #! /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. # Copyright (C) 2010-2015 Antonio Diaz Diaz.
# #
# This configure script is free software: you have unlimited permission # This configure script is free software: you have unlimited permission
# to copy, distribute and modify it. # to copy, distribute and modify it.
pkgname=lunzip pkgname=lunzip
pkgversion=1.7 pkgversion=1.8-pre1
progname=lunzip progname=lunzip
srctrigger=doc/${progname}.1 srctrigger=doc/${progname}.1
@ -164,7 +164,7 @@ echo "CFLAGS = ${CFLAGS}"
echo "LDFLAGS = ${LDFLAGS}" echo "LDFLAGS = ${LDFLAGS}"
rm -f Makefile rm -f Makefile
cat > Makefile << EOF 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. # Copyright (C) 2010-2015 Antonio Diaz Diaz.
# This file was generated automatically by configure. Do not edit. # This file was generated automatically by configure. Do not edit.
# #

View file

@ -1,4 +1,4 @@
/* Lunzip - Decompressor for lzip files /* Lunzip - Decompressor for the lzip format
Copyright (C) 2010-2015 Antonio Diaz Diaz. Copyright (C) 2010-2015 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify 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 ) if( pp->first_post )
{ {
int i, len; int i, len = pp->longest_name - strlen( pp->name );
pp->first_post = false; pp->first_post = false;
fprintf( stderr, " %s: ", pp->name ); fprintf( stderr, " %s: ", pp->name );
len = pp->longest_name - strlen( pp->name ); for( i = 0; i < len; ++i ) fputc( ' ', stderr );
for( i = 0; i < len; ++i ) fprintf( stderr, " " );
if( !msg ) fflush( stderr ); if( !msg ) fflush( stderr );
} }
if( msg ) fprintf( stderr, "%s\n", msg ); if( msg ) fprintf( stderr, "%s\n", msg );
@ -162,7 +161,7 @@ static bool LZd_verify_trailer( struct LZ_decoder * const d,
if( verbosity >= 0 ) if( verbosity >= 0 )
{ {
Pp_show_msg( pp, 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 ) ); trailer_crc, LZd_crc( d ) );
} }
} }
@ -173,7 +172,7 @@ static bool LZd_verify_trailer( struct LZ_decoder * const d,
if( verbosity >= 0 ) if( verbosity >= 0 )
{ {
Pp_show_msg( pp, 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 ) ); 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 ) if( verbosity >= 0 )
{ {
Pp_show_msg( pp, 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 ); trailer_member_size, member_size, member_size );
} }
} }
@ -237,7 +236,7 @@ int LZd_decode_member( struct LZ_decoder * const d,
LZd_peek( d, rep0 ) ) ); LZd_peek( d, rep0 ) ) );
} }
} }
else else /* match or repeated match */
{ {
int len; int len;
if( Rd_decode_bit( rdec, &d->bm_rep[state] ) != 0 ) /* 2nd bit */ 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 ); state = St_set_rep( state );
len = min_match_len + Rd_decode_len( rdec, &d->rep_len_model, pos_state ); len = min_match_len + Rd_decode_len( rdec, &d->rep_len_model, pos_state );
} }
else else /* match */
{ {
int dis_slot; int dis_slot;
const unsigned rep0_saved = rep0; const unsigned rep0_saved = rep0;
@ -301,7 +300,7 @@ int LZd_decode_member( struct LZ_decoder * const d,
if( verbosity >= 0 ) if( verbosity >= 0 )
{ {
Pp_show_msg( pp, 0 ); Pp_show_msg( pp, 0 );
fprintf( stderr, "Unsupported marker code '%d'.\n", len ); fprintf( stderr, "Unsupported marker code '%d'\n", len );
} }
return 4; return 4;
} }

View file

@ -1,4 +1,4 @@
/* Lunzip - Decompressor for lzip files /* Lunzip - Decompressor for the lzip format
Copyright (C) 2010-2015 Antonio Diaz Diaz. Copyright (C) 2010-2015 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify

View file

@ -1,12 +1,12 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.46.1. .\" 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 .SH NAME
lunzip \- decompressor for lzip files lunzip \- decompressor for the lzip format
.SH SYNOPSIS .SH SYNOPSIS
.B lunzip .B lunzip
[\fI\,options\/\fR] [\fI\,files\/\fR] [\fI\,options\/\fR] [\fI\,files\/\fR]
.SH DESCRIPTION .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 small size makes it well suited for embedded devices or software
installers that need to decompress files but do not need compression installers that need to decompress files but do not need compression
capabilities. Lunzip is fully compatible with lzip\-1.4 or newer. capabilities. Lunzip is fully compatible with lzip\-1.4 or newer.

2
lzip.h
View file

@ -1,4 +1,4 @@
/* Lunzip - Decompressor for lzip files /* Lunzip - Decompressor for the lzip format
Copyright (C) 2010-2015 Antonio Diaz Diaz. Copyright (C) 2010-2015 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify

54
main.c
View file

@ -1,4 +1,4 @@
/* Lunzip - Decompressor for lzip files /* Lunzip - Decompressor for the lzip format
Copyright (C) 2010-2015 Antonio Diaz Diaz. Copyright (C) 2010-2015 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify 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 ) 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" "small size makes it well suited for embedded devices or software\n"
"installers that need to decompress files but do not need compression\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" "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" "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" "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" "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" ); "This 'low memory' mode only works when decompressing to a regular file.\n"
printf( "\nUsage: %s [options] [files]\n", invocation_name ); "\nUsage: %s [options] [files]\n", invocation_name );
printf( "\nOptions:\n" printf( "\nOptions:\n"
" -h, --help display this help and exit\n" " -h, --help display this help and exit\n"
" -V, --version output version information 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( infd < 0 )
{ {
if( verbosity >= 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 ) ); program_name, name, strerror( errno ) );
} }
else 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", fprintf( stderr, "%s: Input file '%s' is not a regular file%s.\n",
program_name, name, program_name, name,
( can_read && !no_ofile ) ? ( can_read && !no_ofile ) ?
" and '--stdout' was not specified" : "" ); ",\n and '--stdout' was not specified" : "" );
close( infd ); close( infd );
infd = -1; infd = -1;
} }
@ -301,7 +301,7 @@ static void set_d_outname( const char * const name, const int i )
strcpy( output_filename, name ); strcpy( output_filename, name );
strcat( output_filename, ".out" ); strcat( output_filename, ".out" );
if( verbosity >= 1 ) 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 ); 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", fprintf( stderr, "%s: Output file '%s' already exists, skipping.\n",
program_name, output_filename ); program_name, output_filename );
else 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 ) ); program_name, output_filename, strerror( errno ) );
} }
return ( outfd >= 0 ); 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, static int decompress( const int infd, struct Pretty_print * const pp,
struct Pretty_print * const pp, const bool testing ) const int buffer_size, const bool testing )
{ {
unsigned long long partial_file_pos = 0; unsigned long long partial_file_pos = 0;
struct Range_decoder rdec; struct Range_decoder rdec;
@ -435,20 +435,17 @@ static int decompress( const int buffer_size, const int infd,
if( verbosity >= 0 && result <= 2 ) if( verbosity >= 0 && result <= 2 )
{ {
Pp_show_msg( pp, 0 ); Pp_show_msg( pp, 0 );
if( result == 2 ) fprintf( stderr, "%s at pos %llu\n", ( result == 2 ) ?
fprintf( stderr, "File ends unexpectedly at pos %llu.\n", "File ends unexpectedly" : "Decoder error", partial_file_pos );
partial_file_pos );
else
fprintf( stderr, "Decoder error at pos %llu.\n", partial_file_pos );
} }
retval = 2; break; retval = 2; break;
} }
if( verbosity >= 2 ) 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 ); Rd_free( &rdec );
if( verbosity == 1 && retval == 0 ) if( verbosity == 1 && retval == 0 )
fprintf( stderr, testing ? "ok\n" : "done\n" ); fputs( testing ? "ok\n" : "done\n", stderr );
return retval; return retval;
} }
@ -476,8 +473,8 @@ void show_error( const char * const msg, const int errcode, const bool help )
if( msg && msg[0] ) if( msg && msg[0] )
{ {
fprintf( stderr, "%s: %s", program_name, msg ); fprintf( stderr, "%s: %s", program_name, msg );
if( errcode > 0 ) fprintf( stderr, ": %s.", strerror( errcode ) ); if( errcode > 0 ) fprintf( stderr, ": %s", strerror( errcode ) );
fprintf( stderr, "\n" ); fputc( '\n', stderr );
} }
if( help ) if( help )
fprintf( stderr, "Try '%s --help' for more information.\n", 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 ) if( buffer_size < max_dictionary_size )
{ {
struct stat st;
bool from_stdin = false;
if( to_stdout || testing ) if( to_stdout || testing )
{ show_error( "'--buffer-size' is incompatible with '--stdout' and '--test'.", 0, false ); { show_error( "'--buffer-size' is incompatible with '--stdout' and '--test'.", 0, false );
return 1; } return 1; }
if( !default_output_filename[0] )
for( i = 0; i < num_filenames; ++i ) for( i = 0; i < num_filenames; ++i )
if( !filenames[i][0] || strcmp( filenames[i], "-" ) == 0 ) 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" { show_error( "Output file must be specified when decompressing from stdin with a\n"
" reduced buffer size.", 0, false ); " reduced buffer size.", 0, false ); return 1; }
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 && if( !to_stdout && !testing &&
@ -661,7 +669,7 @@ int main( const int argc, const char * const argv[] )
delete_output_on_interrupt = true; delete_output_on_interrupt = true;
in_statsp = input_filename[0] ? &in_stats : 0; in_statsp = input_filename[0] ? &in_stats : 0;
Pp_set_name( &pp, input_filename ); 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 > retval ) retval = tmp;
if( tmp && !testing ) cleanup_and_fail( retval ); if( tmp && !testing ) cleanup_and_fail( retval );

View file

@ -1,5 +1,5 @@
#! /bin/sh #! /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. # Copyright (C) 2010-2015 Antonio Diaz Diaz.
# #
# This script is free software: you have unlimited permission # This script is free software: you have unlimited permission
@ -75,7 +75,6 @@ printf .
cat in in > in2 || framework_failure cat in in > in2 || framework_failure
cat "${in_lz}" "${in_lz}" > copy2.lz || framework_failure cat "${in_lz}" "${in_lz}" > copy2.lz || framework_failure
"${LZIP}" -t copy2.lz || fail=1 "${LZIP}" -t copy2.lz || fail=1
printf .
"${LZIP}" -cd copy2.lz > copy2 || fail=1 "${LZIP}" -cd copy2.lz > copy2 || fail=1
cmp in2 copy2 || fail=1 cmp in2 copy2 || fail=1
printf . printf .
@ -86,6 +85,7 @@ printf "to be overwritten" > copy2 || framework_failure
cmp in2 copy2 || fail=1 cmp in2 copy2 || fail=1
printf . printf .
rm -f copy
for i in 12 4096 4Ki 29 512KiB ; do for i in 12 4096 4Ki 29 512KiB ; do
printf "to be overwritten" > copy || framework_failure printf "to be overwritten" > copy || framework_failure
"${LZIP}" -df -u$i -o copy < "${in_lz}" || fail=1 "${LZIP}" -df -u$i -o copy < "${in_lz}" || fail=1