Merging upstream version 1.14.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
8e7b6e24fe
commit
3e788f38b7
10 changed files with 98 additions and 100 deletions
|
@ -1,6 +1,6 @@
|
||||||
2024-11-08 Antonio Diaz Diaz <antonio@gnu.org>
|
2025-01-07 Antonio Diaz Diaz <antonio@gnu.org>
|
||||||
|
|
||||||
* Version 1.14-rc1 released.
|
* Version 1.14 released.
|
||||||
* main.c (decompress): Return 2 if empty member in multimember file.
|
* main.c (decompress): Return 2 if empty member in multimember file.
|
||||||
(Pp_free): New function.
|
(Pp_free): New function.
|
||||||
* check.sh: Use 'cp' instead of 'cat'.
|
* check.sh: Use 'cp' instead of 'cat'.
|
||||||
|
@ -125,7 +125,7 @@
|
||||||
* Using LZMA SDK 9.10 (public domain) from Igor Pavlov.
|
* Using LZMA SDK 9.10 (public domain) from Igor Pavlov.
|
||||||
|
|
||||||
|
|
||||||
Copyright (C) 2010-2024 Antonio Diaz Diaz.
|
Copyright (C) 2010-2025 Antonio Diaz Diaz.
|
||||||
|
|
||||||
This file is a collection of facts, and thus it is not copyrightable, but just
|
This file is a collection of facts, and thus it is not copyrightable, but just
|
||||||
in case, you have unlimited permission to copy, distribute, and modify it.
|
in case, you have unlimited permission to copy, distribute, and modify it.
|
||||||
|
|
5
INSTALL
5
INSTALL
|
@ -3,7 +3,8 @@ Requirements
|
||||||
You will need a C99 compiler. (gcc 3.3.6 or newer is recommended).
|
You will need a C99 compiler. (gcc 3.3.6 or newer is recommended).
|
||||||
I use gcc 6.1.0 and 3.3.6, but the code should compile with any standards
|
I use gcc 6.1.0 and 3.3.6, but the code should compile with any standards
|
||||||
compliant compiler.
|
compliant compiler.
|
||||||
Gcc is available at http://gcc.gnu.org.
|
Gcc is available at http://gcc.gnu.org
|
||||||
|
Lzip is available at http://www.nongnu.org/lzip/lzip.html
|
||||||
|
|
||||||
The operating system must allow signal handlers read access to objects with
|
The operating system must allow signal handlers read access to objects with
|
||||||
static storage duration so that the cleanup handler for Control-C can delete
|
static storage duration so that the cleanup handler for Control-C can delete
|
||||||
|
@ -74,7 +75,7 @@ After running 'configure', you can run 'make' and 'make install' as
|
||||||
explained above.
|
explained above.
|
||||||
|
|
||||||
|
|
||||||
Copyright (C) 2010-2024 Antonio Diaz Diaz.
|
Copyright (C) 2010-2025 Antonio Diaz Diaz.
|
||||||
|
|
||||||
This file is free documentation: you have unlimited permission to copy,
|
This file is free documentation: you have unlimited permission to copy,
|
||||||
distribute, and modify it.
|
distribute, and modify it.
|
||||||
|
|
16
README
16
README
|
@ -1,3 +1,5 @@
|
||||||
|
See the file INSTALL for compilation and installation instructions.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
|
|
||||||
Pdlzip is a permissively licensed implementation of the lzip data
|
Pdlzip is a permissively licensed implementation of the lzip data
|
||||||
|
@ -20,11 +22,10 @@ compressed format for Unix-like systems.
|
||||||
The lzip file format is designed for data sharing and long-term archiving,
|
The lzip file format is designed for data sharing and long-term archiving,
|
||||||
taking into account both data integrity and decoder availability:
|
taking into account both data integrity and decoder availability:
|
||||||
|
|
||||||
* The lzip format provides very safe integrity checking and some data
|
* The program lziprecover can repair bit flip errors (one of the most
|
||||||
recovery means. The program lziprecover can repair bit flip errors
|
common forms of data corruption) in lzip files, and provides data
|
||||||
(one of the most common forms of data corruption) in lzip files, and
|
recovery capabilities, including error-checked merging of damaged
|
||||||
provides data recovery capabilities, including error-checked merging
|
copies of a file.
|
||||||
of damaged copies of a file.
|
|
||||||
|
|
||||||
* The lzip format is as simple as possible (but not simpler). The lzip
|
* The lzip format is as simple as possible (but not simpler). The lzip
|
||||||
manual provides the source code of a simple decompressor along with a
|
manual provides the source code of a simple decompressor along with a
|
||||||
|
@ -50,8 +51,11 @@ without recompressing.
|
||||||
Pdlzip includes public domain compression/decompression code from the LZMA
|
Pdlzip includes public domain compression/decompression code from the LZMA
|
||||||
SDK (Software Development Kit) written by Igor Pavlov.
|
SDK (Software Development Kit) written by Igor Pavlov.
|
||||||
|
|
||||||
|
Pdlzip uses Arg_parser for command-line argument parsing:
|
||||||
|
http://www.nongnu.org/arg-parser/arg_parser.html
|
||||||
|
|
||||||
Copyright (C) 2010-2024 Antonio Diaz Diaz.
|
|
||||||
|
Copyright (C) 2010-2025 Antonio Diaz Diaz.
|
||||||
|
|
||||||
This file is free documentation: you have unlimited permission to copy,
|
This file is free documentation: you have unlimited permission to copy,
|
||||||
distribute, and modify it.
|
distribute, and modify it.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* Arg_parser - POSIX/GNU command-line argument parser. (C version)
|
/* Arg_parser - POSIX/GNU command-line argument parser. (C version)
|
||||||
Copyright (C) 2006-2024 Antonio Diaz Diaz.
|
Copyright (C) 2006-2025 Antonio Diaz Diaz.
|
||||||
|
|
||||||
This library is free software. Redistribution and use in source and
|
This library is free software. Redistribution and use in source and
|
||||||
binary forms, with or without modification, are permitted provided
|
binary forms, with or without modification, are permitted provided
|
||||||
|
@ -32,15 +32,15 @@ static void * ap_resize_buffer( void * buf, const int min_size )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char push_back_record( struct Arg_parser * const ap, const int code,
|
static char push_back_record( Arg_parser * const ap, const int code,
|
||||||
const char * const long_name,
|
const char * const long_name,
|
||||||
const char * const argument )
|
const char * const argument )
|
||||||
{
|
{
|
||||||
struct ap_Record * p;
|
ap_Record * p;
|
||||||
void * tmp = ap_resize_buffer( ap->data,
|
void * tmp = ap_resize_buffer( ap->data,
|
||||||
( ap->data_size + 1 ) * sizeof (struct ap_Record) );
|
( ap->data_size + 1 ) * sizeof (ap_Record) );
|
||||||
if( !tmp ) return 0;
|
if( !tmp ) return 0;
|
||||||
ap->data = (struct ap_Record *)tmp;
|
ap->data = (ap_Record *)tmp;
|
||||||
p = &(ap->data[ap->data_size]);
|
p = &(ap->data[ap->data_size]);
|
||||||
p->code = code;
|
p->code = code;
|
||||||
if( long_name )
|
if( long_name )
|
||||||
|
@ -71,7 +71,7 @@ static char push_back_record( struct Arg_parser * const ap, const int code,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char add_error( struct Arg_parser * const ap, const char * const msg )
|
static char add_error( Arg_parser * const ap, const char * const msg )
|
||||||
{
|
{
|
||||||
const int len = strlen( msg );
|
const int len = strlen( msg );
|
||||||
void * tmp = ap_resize_buffer( ap->error, ap->error_size + len + 1 );
|
void * tmp = ap_resize_buffer( ap->error, ap->error_size + len + 1 );
|
||||||
|
@ -83,7 +83,7 @@ static char add_error( struct Arg_parser * const ap, const char * const msg )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void free_data( struct Arg_parser * const ap )
|
static void free_data( Arg_parser * const ap )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for( i = 0; i < ap->data_size; ++i )
|
for( i = 0; i < ap->data_size; ++i )
|
||||||
|
@ -94,10 +94,9 @@ static void free_data( struct Arg_parser * const ap )
|
||||||
|
|
||||||
|
|
||||||
/* Return 0 only if out of memory. */
|
/* Return 0 only if out of memory. */
|
||||||
static char parse_long_option( struct Arg_parser * const ap,
|
static char parse_long_option( Arg_parser * const ap,
|
||||||
const char * const opt, const char * const arg,
|
const char * const opt, const char * const arg,
|
||||||
const struct ap_Option options[],
|
const ap_Option options[], int * const argindp )
|
||||||
int * const argindp )
|
|
||||||
{
|
{
|
||||||
unsigned len;
|
unsigned len;
|
||||||
int index = -1, i;
|
int index = -1, i;
|
||||||
|
@ -171,10 +170,9 @@ static char parse_long_option( struct Arg_parser * const ap,
|
||||||
|
|
||||||
|
|
||||||
/* Return 0 only if out of memory. */
|
/* Return 0 only if out of memory. */
|
||||||
static char parse_short_option( struct Arg_parser * const ap,
|
static char parse_short_option( Arg_parser * const ap,
|
||||||
const char * const opt, const char * const arg,
|
const char * const opt, const char * const arg,
|
||||||
const struct ap_Option options[],
|
const ap_Option options[], int * const argindp )
|
||||||
int * const argindp )
|
|
||||||
{
|
{
|
||||||
int cind = 1; /* character index in opt */
|
int cind = 1; /* character index in opt */
|
||||||
|
|
||||||
|
@ -221,9 +219,9 @@ static char parse_short_option( struct Arg_parser * const ap,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char ap_init( struct Arg_parser * const ap,
|
char ap_init( Arg_parser * const ap,
|
||||||
const int argc, const char * const argv[],
|
const int argc, const char * const argv[],
|
||||||
const struct ap_Option options[], const char in_order )
|
const ap_Option options[], const char in_order )
|
||||||
{
|
{
|
||||||
const char ** non_options = 0; /* skipped non-options */
|
const char ** non_options = 0; /* skipped non-options */
|
||||||
int non_options_size = 0; /* number of skipped non-options */
|
int non_options_size = 0; /* number of skipped non-options */
|
||||||
|
@ -282,7 +280,7 @@ out: if( non_options ) free( non_options );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ap_free( struct Arg_parser * const ap )
|
void ap_free( Arg_parser * const ap )
|
||||||
{
|
{
|
||||||
free_data( ap );
|
free_data( ap );
|
||||||
if( ap->error ) { free( ap->error ); ap->error = 0; }
|
if( ap->error ) { free( ap->error ); ap->error = 0; }
|
||||||
|
@ -290,29 +288,25 @@ void ap_free( struct Arg_parser * const ap )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char * ap_error( const struct Arg_parser * const ap )
|
const char * ap_error( const Arg_parser * const ap ) { return ap->error; }
|
||||||
{ return ap->error; }
|
|
||||||
|
|
||||||
|
int ap_arguments( const Arg_parser * const ap ) { return ap->data_size; }
|
||||||
|
|
||||||
int ap_arguments( const struct Arg_parser * const ap )
|
int ap_code( const Arg_parser * const ap, const int i )
|
||||||
{ return ap->data_size; }
|
|
||||||
|
|
||||||
|
|
||||||
int ap_code( const struct Arg_parser * const ap, const int i )
|
|
||||||
{
|
{
|
||||||
if( i < 0 || i >= ap_arguments( ap ) ) return 0;
|
if( i < 0 || i >= ap_arguments( ap ) ) return 0;
|
||||||
return ap->data[i].code;
|
return ap->data[i].code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char * ap_parsed_name( const struct Arg_parser * const ap, const int i )
|
const char * ap_parsed_name( const Arg_parser * const ap, const int i )
|
||||||
{
|
{
|
||||||
if( i < 0 || i >= ap_arguments( ap ) || !ap->data[i].parsed_name ) return "";
|
if( i < 0 || i >= ap_arguments( ap ) || !ap->data[i].parsed_name ) return "";
|
||||||
return ap->data[i].parsed_name;
|
return ap->data[i].parsed_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char * ap_argument( const struct Arg_parser * const ap, const int i )
|
const char * ap_argument( const Arg_parser * const ap, const int i )
|
||||||
{
|
{
|
||||||
if( i < 0 || i >= ap_arguments( ap ) || !ap->data[i].argument ) return "";
|
if( i < 0 || i >= ap_arguments( ap ) || !ap->data[i].argument ) return "";
|
||||||
return ap->data[i].argument;
|
return ap->data[i].argument;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* Arg_parser - POSIX/GNU command-line argument parser. (C version)
|
/* Arg_parser - POSIX/GNU command-line argument parser. (C version)
|
||||||
Copyright (C) 2006-2024 Antonio Diaz Diaz.
|
Copyright (C) 2006-2025 Antonio Diaz Diaz.
|
||||||
|
|
||||||
This library is free software. Redistribution and use in source and
|
This library is free software. Redistribution and use in source and
|
||||||
binary forms, with or without modification, are permitted provided
|
binary forms, with or without modification, are permitted provided
|
||||||
|
@ -50,52 +50,52 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ap_yme = yes but maybe empty */
|
/* ap_yme = yes but maybe empty */
|
||||||
enum ap_Has_arg { ap_no, ap_yes, ap_maybe, ap_yme };
|
typedef enum ap_Has_arg { ap_no, ap_yes, ap_maybe, ap_yme } ap_Has_arg;
|
||||||
|
|
||||||
struct ap_Option
|
typedef struct ap_Option
|
||||||
{
|
{
|
||||||
int code; /* Short option letter or code ( code != 0 ) */
|
int code; /* Short option letter or code ( code != 0 ) */
|
||||||
const char * long_name; /* Long option name (maybe null) */
|
const char * long_name; /* Long option name (maybe null) */
|
||||||
enum ap_Has_arg has_arg;
|
ap_Has_arg has_arg;
|
||||||
};
|
} ap_Option;
|
||||||
|
|
||||||
|
|
||||||
struct ap_Record
|
typedef struct ap_Record
|
||||||
{
|
{
|
||||||
int code;
|
int code;
|
||||||
char * parsed_name;
|
char * parsed_name;
|
||||||
char * argument;
|
char * argument;
|
||||||
};
|
} ap_Record;
|
||||||
|
|
||||||
|
|
||||||
struct Arg_parser
|
typedef struct Arg_parser
|
||||||
{
|
{
|
||||||
struct ap_Record * data;
|
ap_Record * data;
|
||||||
char * error;
|
char * error;
|
||||||
int data_size;
|
int data_size;
|
||||||
int error_size;
|
int error_size;
|
||||||
};
|
} Arg_parser;
|
||||||
|
|
||||||
|
|
||||||
char ap_init( struct Arg_parser * const ap,
|
char ap_init( Arg_parser * const ap,
|
||||||
const int argc, const char * const argv[],
|
const int argc, const char * const argv[],
|
||||||
const struct ap_Option options[], const char in_order );
|
const ap_Option options[], const char in_order );
|
||||||
|
|
||||||
void ap_free( struct Arg_parser * const ap );
|
void ap_free( Arg_parser * const ap );
|
||||||
|
|
||||||
const char * ap_error( const struct Arg_parser * const ap );
|
const char * ap_error( const Arg_parser * const ap );
|
||||||
|
|
||||||
/* The number of arguments parsed. May be different from argc. */
|
/* The number of arguments parsed. May be different from argc. */
|
||||||
int ap_arguments( const struct Arg_parser * const ap );
|
int ap_arguments( const Arg_parser * const ap );
|
||||||
|
|
||||||
/* If ap_code( i ) is 0, ap_argument( i ) is a non-option.
|
/* If ap_code( i ) is 0, ap_argument( i ) is a non-option.
|
||||||
Else ap_argument( i ) is the option's argument (or empty). */
|
Else ap_argument( i ) is the option's argument (or empty). */
|
||||||
int ap_code( const struct Arg_parser * const ap, const int i );
|
int ap_code( const Arg_parser * const ap, const int i );
|
||||||
|
|
||||||
/* Full name of the option parsed (short or long). */
|
/* Full name of the option parsed (short or long). */
|
||||||
const char * ap_parsed_name( const struct Arg_parser * const ap, const int i );
|
const char * ap_parsed_name( const Arg_parser * const ap, const int i );
|
||||||
|
|
||||||
const char * ap_argument( const struct Arg_parser * const ap, const int i );
|
const char * ap_argument( const Arg_parser * const ap, const int i );
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
6
configure
vendored
6
configure
vendored
|
@ -1,12 +1,12 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# configure script for Pdlzip - LZMA lossless data compressor
|
# configure script for Pdlzip - LZMA lossless data compressor
|
||||||
# Copyright (C) 2010-2024 Antonio Diaz Diaz.
|
# Copyright (C) 2010-2025 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=pdlzip
|
pkgname=pdlzip
|
||||||
pkgversion=1.14-rc1
|
pkgversion=1.14
|
||||||
progname=pdlzip
|
progname=pdlzip
|
||||||
srctrigger=doc/${progname}.1
|
srctrigger=doc/${progname}.1
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ echo "MAKEINFO = ${MAKEINFO}"
|
||||||
rm -f Makefile
|
rm -f Makefile
|
||||||
cat > Makefile << EOF
|
cat > Makefile << EOF
|
||||||
# Makefile for Pdlzip - LZMA lossless data compressor
|
# Makefile for Pdlzip - LZMA lossless data compressor
|
||||||
# Copyright (C) 2010-2024 Antonio Diaz Diaz.
|
# Copyright (C) 2010-2025 Antonio Diaz Diaz.
|
||||||
# This file was generated automatically by configure. Don't edit.
|
# This file was generated automatically by configure. Don't edit.
|
||||||
#
|
#
|
||||||
# This Makefile is free software: you have unlimited permission
|
# This Makefile is free software: you have unlimited permission
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.2.
|
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.2.
|
||||||
.TH PDLZIP "1" "November 2024" "pdlzip 1.14-rc1" "User Commands"
|
.TH PDLZIP "1" "January 2025" "pdlzip 1.14" "User Commands"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
pdlzip \- reduces the size of files
|
pdlzip \- reduces the size of files
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
@ -112,7 +112,7 @@ Report bugs to lzip\-bug@nongnu.org
|
||||||
.br
|
.br
|
||||||
Pdlzip home page: http://www.nongnu.org/lzip/pdlzip.html
|
Pdlzip home page: http://www.nongnu.org/lzip/pdlzip.html
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
Copyright \(co 2024 Antonio Diaz Diaz.
|
Copyright \(co 2025 Antonio Diaz Diaz.
|
||||||
Public Domain 2009 Igor Pavlov.
|
Public Domain 2009 Igor Pavlov.
|
||||||
License 2\-clause BSD.
|
License 2\-clause BSD.
|
||||||
.br
|
.br
|
||||||
|
|
10
lzip.h
10
lzip.h
|
@ -1,5 +1,5 @@
|
||||||
/* Pdlzip - LZMA lossless data compressor
|
/* Pdlzip - LZMA lossless data compressor
|
||||||
Copyright (C) 2010-2024 Antonio Diaz Diaz.
|
Copyright (C) 2010-2025 Antonio Diaz Diaz.
|
||||||
|
|
||||||
This program is free software. Redistribution and use in source and
|
This program is free software. Redistribution and use in source and
|
||||||
binary forms, with or without modification, are permitted provided
|
binary forms, with or without modification, are permitted provided
|
||||||
|
@ -188,13 +188,13 @@ static inline void Lt_set_member_size( Lzip_trailer data, unsigned long long sz
|
||||||
{ int i; for( i = 12; i <= 19; ++i ) { data[i] = (uint8_t)sz; sz >>= 8; } }
|
{ int i; for( i = 12; i <= 19; ++i ) { data[i] = (uint8_t)sz; sz >>= 8; } }
|
||||||
|
|
||||||
|
|
||||||
struct Cl_options /* command-line options */
|
typedef struct Cl_options /* command-line options */
|
||||||
{
|
{
|
||||||
bool ignore_trailing;
|
bool ignore_trailing;
|
||||||
bool loose_trailing;
|
bool loose_trailing;
|
||||||
};
|
} Cl_options;
|
||||||
|
|
||||||
static inline void Cl_options_init( struct Cl_options * cl_opts )
|
static inline void Cl_options_init( Cl_options * cl_opts )
|
||||||
{ cl_opts->ignore_trailing = true; cl_opts->loose_trailing = false; }
|
{ cl_opts->ignore_trailing = true; cl_opts->loose_trailing = false; }
|
||||||
|
|
||||||
|
|
||||||
|
@ -202,8 +202,8 @@ static inline void set_retval( int * retval, const int new_val )
|
||||||
{ if( *retval < new_val ) *retval = new_val; }
|
{ if( *retval < new_val ) *retval = new_val; }
|
||||||
|
|
||||||
static const char * const empty_msg = "Empty member not allowed.";
|
static const char * const empty_msg = "Empty member not allowed.";
|
||||||
static const char * const trailing_msg = "Trailing data not allowed.";
|
|
||||||
static const char * const mem_msg = "Not enough memory.";
|
static const char * const mem_msg = "Not enough memory.";
|
||||||
|
static const char * const trailing_msg = "Trailing data not allowed.";
|
||||||
|
|
||||||
/* defined in main.c */
|
/* defined in main.c */
|
||||||
extern int verbosity;
|
extern int verbosity;
|
||||||
|
|
66
main.c
66
main.c
|
@ -1,6 +1,6 @@
|
||||||
/* Pdlzip - LZMA lossless data compressor
|
/* Pdlzip - LZMA lossless data compressor
|
||||||
2009-08-14 : Igor Pavlov : Public domain
|
2009-08-14 : Igor Pavlov : Public domain
|
||||||
Copyright (C) 2010-2024 Antonio Diaz Diaz.
|
Copyright (C) 2010-2025 Antonio Diaz Diaz.
|
||||||
|
|
||||||
This program is free software. Redistribution and use in source and
|
This program is free software. Redistribution and use in source and
|
||||||
binary forms, with or without modification, are permitted provided
|
binary forms, with or without modification, are permitted provided
|
||||||
|
@ -85,7 +85,7 @@ static void show_file_error( const char * const filename,
|
||||||
static void internal_error( const char * const msg );
|
static void internal_error( const char * const msg );
|
||||||
|
|
||||||
static const char * const program_name = "pdlzip";
|
static const char * const program_name = "pdlzip";
|
||||||
static const char * const program_year = "2024";
|
static const char * const program_year = "2025";
|
||||||
static const char * invocation_name = "pdlzip"; /* default value */
|
static const char * invocation_name = "pdlzip"; /* default value */
|
||||||
|
|
||||||
static const struct { const char * from; const char * to; } known_extensions[] = {
|
static const struct { const char * from; const char * to; } known_extensions[] = {
|
||||||
|
@ -94,13 +94,13 @@ static const struct { const char * from; const char * to; } known_extensions[] =
|
||||||
{ ".lzma", "" },
|
{ ".lzma", "" },
|
||||||
{ 0, 0 } };
|
{ 0, 0 } };
|
||||||
|
|
||||||
struct Lzma_options
|
typedef struct Lzma_options
|
||||||
{
|
{
|
||||||
int dictionary_size; /* 4 KiB .. 512 MiB */
|
int dictionary_size; /* 4 KiB .. 512 MiB */
|
||||||
int match_len_limit; /* 5 .. 273 */
|
int match_len_limit; /* 5 .. 273 */
|
||||||
};
|
} Lzma_options;
|
||||||
|
|
||||||
enum Mode { m_compress, m_decompress, m_test };
|
typedef enum Mode { m_compress, m_decompress, m_test } Mode;
|
||||||
|
|
||||||
/* Variables used in signal handler context.
|
/* Variables used in signal handler context.
|
||||||
They are not declared volatile because the handler never returns. */
|
They are not declared volatile because the handler never returns. */
|
||||||
|
@ -196,16 +196,16 @@ static void * resize_buffer( void * buf, const unsigned min_size )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct Pretty_print
|
typedef struct Pretty_print
|
||||||
{
|
{
|
||||||
const char * name;
|
const char * name;
|
||||||
char * padded_name;
|
char * padded_name;
|
||||||
const char * stdin_name;
|
const char * stdin_name;
|
||||||
unsigned longest_name;
|
unsigned longest_name;
|
||||||
bool first_post;
|
bool first_post;
|
||||||
};
|
} Pretty_print;
|
||||||
|
|
||||||
static void Pp_init( struct Pretty_print * const pp,
|
static void Pp_init( Pretty_print * const pp,
|
||||||
const char * const filenames[], const int num_filenames )
|
const char * const filenames[], const int num_filenames )
|
||||||
{
|
{
|
||||||
pp->name = 0;
|
pp->name = 0;
|
||||||
|
@ -226,11 +226,10 @@ static void Pp_init( struct Pretty_print * const pp,
|
||||||
if( pp->longest_name == 0 ) pp->longest_name = stdin_name_len;
|
if( pp->longest_name == 0 ) pp->longest_name = stdin_name_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pp_free( struct Pretty_print * const pp )
|
void Pp_free( Pretty_print * const pp )
|
||||||
{ if( pp->padded_name ) { free( pp->padded_name ); pp->padded_name = 0; } }
|
{ if( pp->padded_name ) { free( pp->padded_name ); pp->padded_name = 0; } }
|
||||||
|
|
||||||
static void Pp_set_name( struct Pretty_print * const pp,
|
static void Pp_set_name( Pretty_print * const pp, const char * const filename )
|
||||||
const char * const filename )
|
|
||||||
{
|
{
|
||||||
unsigned name_len, padded_name_len, i = 0;
|
unsigned name_len, padded_name_len, i = 0;
|
||||||
|
|
||||||
|
@ -248,10 +247,10 @@ static void Pp_set_name( struct Pretty_print * const pp,
|
||||||
pp->first_post = true;
|
pp->first_post = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Pp_reset( struct Pretty_print * const pp )
|
static void Pp_reset( Pretty_print * const pp )
|
||||||
{ if( pp->name && pp->name[0] ) pp->first_post = true; }
|
{ if( pp->name && pp->name[0] ) pp->first_post = true; }
|
||||||
|
|
||||||
static void Pp_show_msg( struct Pretty_print * const pp, const char * const msg )
|
static void Pp_show_msg( Pretty_print * const pp, const char * const msg )
|
||||||
{
|
{
|
||||||
if( verbosity < 0 ) return;
|
if( verbosity < 0 ) return;
|
||||||
if( pp->first_post )
|
if( pp->first_post )
|
||||||
|
@ -280,7 +279,7 @@ static void show_header( const unsigned dictionary_size )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* separate numbers of 6 or more digits in groups of 3 digits using '_' */
|
/* separate numbers of 5 or more digits in groups of 3 digits using '_' */
|
||||||
static const char * format_num3( unsigned long long num )
|
static const char * format_num3( unsigned long long num )
|
||||||
{
|
{
|
||||||
enum { buffers = 8, bufsize = 4 * sizeof num, n = 10 };
|
enum { buffers = 8, bufsize = 4 * sizeof num, n = 10 };
|
||||||
|
@ -303,7 +302,7 @@ static const char * format_num3( unsigned long long num )
|
||||||
{ num /= 1000; prefix = si_prefix[i]; }
|
{ num /= 1000; prefix = si_prefix[i]; }
|
||||||
if( prefix ) *(--p) = prefix;
|
if( prefix ) *(--p) = prefix;
|
||||||
}
|
}
|
||||||
const bool split = num >= 100000;
|
const bool split = num >= 10000;
|
||||||
|
|
||||||
for( i = 0; ; )
|
for( i = 0; ; )
|
||||||
{
|
{
|
||||||
|
@ -388,7 +387,7 @@ static int get_dict_size( const char * const arg, const char * const option_name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void set_mode( enum Mode * const program_modep, const enum Mode new_mode )
|
static void set_mode( Mode * const program_modep, const Mode new_mode )
|
||||||
{
|
{
|
||||||
if( *program_modep != m_compress && *program_modep != new_mode )
|
if( *program_modep != m_compress && *program_modep != new_mode )
|
||||||
{
|
{
|
||||||
|
@ -455,7 +454,7 @@ static void set_d_outname( const char * const name, const int eindex )
|
||||||
|
|
||||||
|
|
||||||
static int open_instream( const char * const name, struct stat * const in_statsp,
|
static int open_instream( const char * const name, struct stat * const in_statsp,
|
||||||
const enum Mode program_mode, const int eindex,
|
const Mode program_mode, const int eindex,
|
||||||
const bool one_to_one, const bool recompress )
|
const bool one_to_one, const bool recompress )
|
||||||
{
|
{
|
||||||
if( program_mode == m_compress && !recompress && eindex >= 0 )
|
if( program_mode == m_compress && !recompress && eindex >= 0 )
|
||||||
|
@ -540,7 +539,7 @@ static void signal_handler( int sig )
|
||||||
|
|
||||||
|
|
||||||
static bool check_tty_in( const char * const input_filename, const int infd,
|
static bool check_tty_in( const char * const input_filename, const int infd,
|
||||||
const enum Mode program_mode, int * const retval )
|
const Mode program_mode, int * const retval )
|
||||||
{
|
{
|
||||||
if( ( program_mode == m_decompress || program_mode == m_test ) &&
|
if( ( program_mode == m_decompress || program_mode == m_test ) &&
|
||||||
isatty( infd ) ) /* for example /dev/tty */
|
isatty( infd ) ) /* for example /dev/tty */
|
||||||
|
@ -552,7 +551,7 @@ static bool check_tty_in( const char * const input_filename, const int infd,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool check_tty_out( const enum Mode program_mode )
|
static bool check_tty_out( const Mode program_mode )
|
||||||
{
|
{
|
||||||
if( program_mode == m_compress && isatty( outfd ) )
|
if( program_mode == m_compress && isatty( outfd ) )
|
||||||
{ show_file_error( output_filename[0] ?
|
{ show_file_error( output_filename[0] ?
|
||||||
|
@ -596,8 +595,9 @@ static void close_and_set_permissions( const struct stat * const in_statsp )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int compress( const int infd, const struct Lzma_options * const
|
static int compress( const int infd,
|
||||||
encoder_options, struct Pretty_print * const pp )
|
const Lzma_options * const encoder_options,
|
||||||
|
Pretty_print * const pp )
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
CLzmaEncHandle encoder = 0;
|
CLzmaEncHandle encoder = 0;
|
||||||
|
@ -734,8 +734,8 @@ static int lzma_decode( uint64_t unpackSize, CLzmaDec *decoder, const int infd,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int lzip_decode( CLzmaDec *decoder, const int infd,
|
static int lzip_decode( CLzmaDec * decoder, const int infd,
|
||||||
struct Pretty_print * const pp, uint8_t inBuf[],
|
Pretty_print * const pp, uint8_t inBuf[],
|
||||||
int * const inPos, int * const inSize,
|
int * const inPos, int * const inSize,
|
||||||
const unsigned dictionary_size, bool * const data0p )
|
const unsigned dictionary_size, bool * const data0p )
|
||||||
{
|
{
|
||||||
|
@ -840,8 +840,8 @@ static int lzip_decode( CLzmaDec *decoder, const int infd,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int decompress( const int infd, const struct Cl_options * const cl_opts,
|
static int decompress( const int infd, const Cl_options * const cl_opts,
|
||||||
struct Pretty_print * const pp,
|
Pretty_print * const pp,
|
||||||
const bool from_stdin, const bool testing )
|
const bool from_stdin, const bool testing )
|
||||||
{
|
{
|
||||||
uint64_t unpackSize = 0;
|
uint64_t unpackSize = 0;
|
||||||
|
@ -1031,7 +1031,7 @@ int main( const int argc, const char * const argv[] )
|
||||||
{
|
{
|
||||||
/* Mapping from gzip/bzip2 style 0..9 compression levels to the
|
/* Mapping from gzip/bzip2 style 0..9 compression levels to the
|
||||||
corresponding LZMA compression parameters. */
|
corresponding LZMA compression parameters. */
|
||||||
const struct Lzma_options option_mapping[] =
|
const Lzma_options option_mapping[] =
|
||||||
{
|
{
|
||||||
{ 1 << 16, 5 }, /* -0 */
|
{ 1 << 16, 5 }, /* -0 */
|
||||||
{ 1 << 20, 5 }, /* -1 */
|
{ 1 << 20, 5 }, /* -1 */
|
||||||
|
@ -1043,11 +1043,10 @@ int main( const int argc, const char * const argv[] )
|
||||||
{ 1 << 24, 68 }, /* -7 */
|
{ 1 << 24, 68 }, /* -7 */
|
||||||
{ 3 << 23, 132 }, /* -8 */
|
{ 3 << 23, 132 }, /* -8 */
|
||||||
{ 1 << 25, 273 } }; /* -9 */
|
{ 1 << 25, 273 } }; /* -9 */
|
||||||
struct Lzma_options encoder_options = option_mapping[6]; /* default = "-6" */
|
Lzma_options encoder_options = option_mapping[6]; /* default = "-6" */
|
||||||
const char * default_output_filename = "";
|
const char * default_output_filename = "";
|
||||||
enum Mode program_mode = m_compress;
|
Mode program_mode = m_compress;
|
||||||
int i;
|
Cl_options cl_opts; /* command-line options */
|
||||||
struct Cl_options cl_opts; /* command-line options */
|
|
||||||
Cl_options_init( &cl_opts );
|
Cl_options_init( &cl_opts );
|
||||||
bool force = false;
|
bool force = false;
|
||||||
bool keep_input_files = false;
|
bool keep_input_files = false;
|
||||||
|
@ -1056,7 +1055,7 @@ int main( const int argc, const char * const argv[] )
|
||||||
if( argc > 0 ) invocation_name = argv[0];
|
if( argc > 0 ) invocation_name = argv[0];
|
||||||
|
|
||||||
enum { opt_lt = 256 };
|
enum { opt_lt = 256 };
|
||||||
const struct ap_Option options[] =
|
const ap_Option options[] =
|
||||||
{
|
{
|
||||||
{ '0', "fast", ap_no },
|
{ '0', "fast", ap_no },
|
||||||
{ '1', 0, ap_no },
|
{ '1', 0, ap_no },
|
||||||
|
@ -1091,7 +1090,7 @@ int main( const int argc, const char * const argv[] )
|
||||||
CRC32_init();
|
CRC32_init();
|
||||||
|
|
||||||
/* static because valgrind complains and memory management in C sucks */
|
/* static because valgrind complains and memory management in C sucks */
|
||||||
static struct Arg_parser parser;
|
static Arg_parser parser;
|
||||||
if( !ap_init( &parser, argc, argv, options, 0 ) )
|
if( !ap_init( &parser, argc, argv, options, 0 ) )
|
||||||
{ show_error( mem_msg, 0, false ); return 1; }
|
{ show_error( mem_msg, 0, false ); return 1; }
|
||||||
if( ap_error( &parser ) ) /* bad option */
|
if( ap_error( &parser ) ) /* bad option */
|
||||||
|
@ -1144,6 +1143,7 @@ int main( const int argc, const char * const argv[] )
|
||||||
filenames = resize_buffer( filenames, num_filenames * sizeof filenames[0] );
|
filenames = resize_buffer( filenames, num_filenames * sizeof filenames[0] );
|
||||||
filenames[0] = "-";
|
filenames[0] = "-";
|
||||||
|
|
||||||
|
int i;
|
||||||
bool filenames_given = false;
|
bool filenames_given = false;
|
||||||
for( i = 0; argind + i < ap_arguments( &parser ); ++i )
|
for( i = 0; argind + i < ap_arguments( &parser ); ++i )
|
||||||
{
|
{
|
||||||
|
@ -1165,7 +1165,7 @@ int main( const int argc, const char * const argv[] )
|
||||||
if( !to_stdout && program_mode != m_test && ( filenames_given || to_file ) )
|
if( !to_stdout && program_mode != m_test && ( filenames_given || to_file ) )
|
||||||
set_signals( signal_handler );
|
set_signals( signal_handler );
|
||||||
|
|
||||||
static struct Pretty_print pp;
|
static Pretty_print pp;
|
||||||
Pp_init( &pp, filenames, num_filenames );
|
Pp_init( &pp, filenames, num_filenames );
|
||||||
|
|
||||||
int failed_tests = 0;
|
int failed_tests = 0;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# check script for Pdlzip - LZMA lossless data compressor
|
# check script for Pdlzip - LZMA lossless data compressor
|
||||||
# Copyright (C) 2010-2024 Antonio Diaz Diaz.
|
# Copyright (C) 2010-2025 Antonio Diaz Diaz.
|
||||||
#
|
#
|
||||||
# This script is free software: you have unlimited permission
|
# This script is free software: you have unlimited permission
|
||||||
# to copy, distribute, and modify it.
|
# to copy, distribute, and modify it.
|
||||||
|
@ -128,7 +128,6 @@ rm -f copy out || framework_failure
|
||||||
printf "to be overwritten" > out || framework_failure
|
printf "to be overwritten" > out || framework_failure
|
||||||
"${LZIP}" -df -o out < "${in_lz}" || test_failed $LINENO
|
"${LZIP}" -df -o out < "${in_lz}" || test_failed $LINENO
|
||||||
cmp in out || test_failed $LINENO
|
cmp in out || test_failed $LINENO
|
||||||
rm -f out || framework_failure
|
|
||||||
"${LZIP}" -d -o ./- "${in_lz}" || test_failed $LINENO
|
"${LZIP}" -d -o ./- "${in_lz}" || test_failed $LINENO
|
||||||
cmp in ./- || test_failed $LINENO
|
cmp in ./- || test_failed $LINENO
|
||||||
rm -f ./- || framework_failure
|
rm -f ./- || framework_failure
|
||||||
|
@ -141,7 +140,7 @@ cp "${in_lz}" anyothername || framework_failure
|
||||||
test_failed $LINENO
|
test_failed $LINENO
|
||||||
cmp in out || test_failed $LINENO
|
cmp in out || test_failed $LINENO
|
||||||
cmp in anyothername.out || test_failed $LINENO
|
cmp in anyothername.out || test_failed $LINENO
|
||||||
rm -f out anyothername.out || framework_failure
|
rm -f anyothername.out || framework_failure
|
||||||
|
|
||||||
"${LZIP}" -tq in "${in_lz}"
|
"${LZIP}" -tq in "${in_lz}"
|
||||||
[ $? = 2 ] || test_failed $LINENO
|
[ $? = 2 ] || test_failed $LINENO
|
||||||
|
|
Loading…
Add table
Reference in a new issue