1
0
Fork 0

Adding upstream version 1.5~rc2.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-17 22:14:05 +01:00
parent df42bf1fa4
commit 25083e3fd1
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
14 changed files with 215 additions and 255 deletions

47
main.c
View file

@ -1,5 +1,5 @@
/* Lunzip - Decompressor for lzip files
Copyright (C) 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
Copyright (C) 2010, 2011, 2012, 2013, 2014 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -65,7 +65,7 @@
const char * const Program_name = "Lunzip";
const char * const program_name = "lunzip";
const char * const program_year = "2013";
const char * const program_year = "2014";
const char * invocation_name = 0;
struct { const char * from; const char * to; } const known_extensions[] = {
@ -130,14 +130,14 @@ static void show_version( void )
}
static void show_header( const File_header header )
static void show_header( const unsigned dictionary_size )
{
const char * const prefix[8] =
{ "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi" };
enum { factor = 1024 };
const char * p = "";
const char * np = " ";
unsigned num = Fh_get_dictionary_size( header ), i;
unsigned num = dictionary_size, i;
bool exact = ( num % factor == 0 );
for( i = 0; i < 8 && ( num > 9999 || ( exact && num >= factor ) ); ++i )
@ -231,7 +231,9 @@ static int extension_index( const char * const name )
static int open_instream( const char * const name, struct stat * const in_statsp,
const bool no_ofile )
{
int infd = open( name, O_RDONLY | O_BINARY );
int infd;
do infd = open( name, O_RDONLY | O_BINARY );
while( infd < 0 && errno == EINTR );
if( infd < 0 )
{
if( verbosity >= 0 )
@ -303,7 +305,8 @@ static bool open_outstream( const bool force )
int flags = O_APPEND | O_CREAT | O_RDWR | O_BINARY;
if( force ) flags |= O_TRUNC; else flags |= O_EXCL;
outfd = open( output_filename, flags, outfd_mode );
do outfd = open( output_filename, flags, outfd_mode );
while( outfd < 0 && errno == EINTR );
if( outfd < 0 && verbosity >= 0 )
{
if( errno == EEXIST )
@ -379,6 +382,7 @@ static int decompress( const int buffer_size, const int infd,
for( first_member = true; ; first_member = false )
{
int result;
unsigned dictionary_size;
File_header header;
struct LZ_decoder decoder;
Rd_reset_member_position( &rdec );
@ -404,15 +408,17 @@ static int decompress( const int buffer_size, const int infd,
Fh_version( header ) ); }
retval = 2; break;
}
if( Fh_get_dictionary_size( header ) < min_dictionary_size ||
Fh_get_dictionary_size( header ) > max_dictionary_size )
dictionary_size = Fh_get_dictionary_size( header );
if( dictionary_size < min_dictionary_size ||
dictionary_size > max_dictionary_size )
{ Pp_show_msg( pp, "Invalid dictionary size in member header" );
retval = 2; break; }
if( verbosity >= 2 || ( verbosity == 1 && first_member ) )
{ Pp_show_msg( pp, 0 ); if( verbosity >= 3 ) show_header( header ); }
{ Pp_show_msg( pp, 0 );
if( verbosity >= 3 ) show_header( dictionary_size ); }
if( !LZd_init( &decoder, header, &rdec, buffer_size, outfd ) )
if( !LZd_init( &decoder, &rdec, buffer_size, dictionary_size, outfd ) )
{
show_error( "Not enough memory. Try a smaller output buffer size.", 0, false );
cleanup_and_fail( 1 );
@ -459,27 +465,6 @@ static void set_signals( void )
}
void Pp_init( struct Pretty_print * const pp, const char * const filenames[],
const int num_filenames )
{
unsigned stdin_name_len;
int i;
pp->name = 0;
pp->stdin_name = "(stdin)";
pp->longest_name = 0;
pp->first_post = false;
stdin_name_len = strlen( pp->stdin_name );
for( i = 0; i < num_filenames; ++i )
{
const char * const s = filenames[i];
const int len = ( (strcmp( s, "-" ) == 0) ? stdin_name_len : strlen( s ) );
if( len > pp->longest_name ) pp->longest_name = len;
}
if( pp->longest_name == 0 ) pp->longest_name = stdin_name_len;
}
void show_error( const char * const msg, const int errcode, const bool help )
{
if( verbosity >= 0 )