From dc114ed0e55813f66a71a56276bc81db6dfa16f1 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 25 Jan 2021 13:43:54 +0100 Subject: Adding upstream version 1.12. Signed-off-by: Daniel Baumann --- list.c | 55 +++++++++++++++++++++++-------------------------------- 1 file changed, 23 insertions(+), 32 deletions(-) (limited to 'list.c') diff --git a/list.c b/list.c index 15ee8e8..dbf79bc 100644 --- a/list.c +++ b/list.c @@ -1,26 +1,26 @@ -/* Clzip - LZMA lossless data compressor - Copyright (C) 2010-2019 Antonio Diaz Diaz. +/* Clzip - LZMA lossless data compressor + Copyright (C) 2010-2021 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 - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. + 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 + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see . + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ #define _FILE_OFFSET_BITS 64 #include +#include #include #include -#include #include #include @@ -33,11 +33,11 @@ static void list_line( const unsigned long long uncomp_size, const char * const input_filename ) { if( uncomp_size > 0 ) - printf( "%15llu %15llu %6.2f%% %s\n", uncomp_size, comp_size, + printf( "%14llu %14llu %6.2f%% %s\n", uncomp_size, comp_size, 100.0 - ( ( 100.0 * comp_size ) / uncomp_size ), input_filename ); else - printf( "%15llu %15llu -INF%% %s\n", uncomp_size, comp_size, + printf( "%14llu %14llu -INF%% %s\n", uncomp_size, comp_size, input_filename ); } @@ -60,15 +60,15 @@ int list_files( const char * const filenames[], const int num_filenames, if( from_stdin ) { if( stdin_used ) continue; else stdin_used = true; } input_filename = from_stdin ? "(stdin)" : filenames[i]; infd = from_stdin ? STDIN_FILENO : - open_instream( input_filename, &in_stats, true, true ); - if( infd < 0 ) { if( retval < 1 ) retval = 1; continue; } + open_instream( input_filename, &in_stats, false, true ); + if( infd < 0 ) { set_retval( &retval, 1 ); continue; } Li_init( &lzip_index, infd, ignore_trailing, loose_trailing ); close( infd ); if( lzip_index.retval != 0 ) { show_file_error( input_filename, lzip_index.error, 0 ); - if( retval < lzip_index.retval ) retval = lzip_index.retval; + set_retval( &retval, lzip_index.retval ); Li_free( &lzip_index ); continue; } if( verbosity >= 0 ) @@ -80,31 +80,22 @@ int list_files( const char * const filenames[], const int num_filenames, { first_post = false; if( verbosity >= 1 ) fputs( " dict memb trail ", stdout ); - fputs( " uncompressed compressed saved name\n", stdout ); + fputs( " uncompressed compressed saved name\n", stdout ); } if( verbosity >= 1 ) - { - long long trailing_size; - unsigned dictionary_size = 0; - long i; - for( i = 0; i < lzip_index.members; ++i ) - dictionary_size = - max( dictionary_size, Li_dictionary_size( &lzip_index, i ) ); - trailing_size = Li_file_size( &lzip_index ) - cdata_size; - printf( "%s %5ld %6lld ", format_ds( dictionary_size ), - lzip_index.members, trailing_size ); - } + printf( "%s %5ld %6lld ", format_ds( lzip_index.dictionary_size ), + lzip_index.members, Li_file_size( &lzip_index ) - cdata_size ); list_line( udata_size, cdata_size, input_filename ); if( verbosity >= 2 && lzip_index.members > 1 ) { long i; - fputs( " member data_pos data_size member_pos member_size\n", stdout ); + fputs( " member data_pos data_size member_pos member_size\n", stdout ); for( i = 0; i < lzip_index.members; ++i ) { const struct Block * db = Li_dblock( &lzip_index, i ); const struct Block * mb = Li_mblock( &lzip_index, i ); - printf( "%5ld %15llu %15llu %15llu %15llu\n", + printf( "%6ld %14llu %14llu %14llu %14llu\n", i + 1, db->pos, db->size, mb->pos, mb->size ); } first_post = true; /* reprint heading after list of members */ -- cgit v1.2.3