1
0
Fork 0

Adding upstream version 1.0~rc3.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-23 19:09:32 +01:00
parent 86939b5884
commit 0e02cf2f93
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
8 changed files with 58 additions and 43 deletions

View file

@ -1,3 +1,8 @@
2010-03-14 Antonio Diaz Diaz <ant_diaz@teleline.es>
* Version 1.0-rc3 released.
* Remove some sizeofs and make other small changes.
2010-02-27 Antonio Diaz Diaz <ant_diaz@teleline.es> 2010-02-27 Antonio Diaz Diaz <ant_diaz@teleline.es>
* Version 1.0-rc2 released. * Version 1.0-rc2 released.

View file

@ -141,7 +141,7 @@ void MatchFinder_Construct(CMatchFinder *p)
p->directInput = 0; p->directInput = 0;
p->hash = 0; p->hash = 0;
MatchFinder_SetDefaultSettings(p); MatchFinder_SetDefaultSettings(p);
p->crc = 0xFFFFFFFF; p->crc = 0xFFFFFFFFU;
} }
static void MatchFinder_FreeThisClassMemory(CMatchFinder *p, ISzAlloc *alloc) static void MatchFinder_FreeThisClassMemory(CMatchFinder *p, ISzAlloc *alloc)

View file

@ -1574,15 +1574,15 @@ static void LZe_full_flush(CLzmaEnc *p, UInt32 posState)
RangeEnc_FlushData(&p->rc); RangeEnc_FlushData(&p->rc);
RangeEnc_FlushStream(&p->rc); RangeEnc_FlushStream(&p->rc);
File_trailer trailer; File_trailer trailer;
Ft_set_data_crc( trailer, p->matchFinderBase.crc ^ 0xFFFFFFFF ); Ft_set_data_crc( trailer, p->matchFinderBase.crc ^ 0xFFFFFFFFU );
Ft_set_data_size( trailer, p->nowPos64 ); Ft_set_data_size( trailer, p->nowPos64 );
Ft_set_member_size( trailer, p->rc.processed + sizeof (File_header) + sizeof (File_trailer) ); Ft_set_member_size( trailer, p->rc.processed + Fh_size + Ft_size );
if( p->rc.outStream->Write( p->rc.outStream, trailer, sizeof (File_trailer)) != sizeof (File_trailer)) if( p->rc.outStream->Write( p->rc.outStream, trailer, Ft_size ) != Ft_size )
p->rc.res = SZ_ERROR_WRITE; p->rc.res = SZ_ERROR_WRITE;
if( verbosity >= 1 ) if( verbosity >= 1 )
{ {
long long in_size = p->nowPos64; long long in_size = p->nowPos64;
long long out_size = p->rc.processed + sizeof (File_header) + sizeof (File_trailer); long long out_size = p->rc.processed + Fh_size + Ft_size;
if( in_size <= 0 || out_size <= 0 ) if( in_size <= 0 || out_size <= 0 )
fprintf( stderr, "no data compressed.\n" ); fprintf( stderr, "no data compressed.\n" );
else else

4
configure vendored
View file

@ -5,12 +5,12 @@
# 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.
# #
# Date of this version: 2010-02-27 # Date of this version: 2010-03-14
args= args=
no_create= no_create=
pkgname=pdlzip pkgname=pdlzip
pkgversion=1.0-rc2 pkgversion=1.0-rc3
progname=pdlzip progname=pdlzip
srctrigger=pdlzip.h srctrigger=pdlzip.h

View file

@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36. .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36.
.TH PDLZIP "1" "February 2010" "Pdlzip 1.0-rc2" "User Commands" .TH PDLZIP "1" "March 2010" "Pdlzip 1.0-rc3" "User Commands"
.SH NAME .SH NAME
Pdlzip \- data compressor based on the LZMA algorithm Pdlzip \- data compressor based on the LZMA algorithm
.SH SYNOPSIS .SH SYNOPSIS

39
main.c
View file

@ -28,6 +28,10 @@
#include "LzmaDec.h" #include "LzmaDec.h"
#include "LzmaEnc.h" #include "LzmaEnc.h"
#if CHAR_BIT != 8
#error "Environments where CHAR_BIT != 8 are not supported."
#endif
static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); } static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); }
static void SzFree(void *p, void *address) { p = p; MyFree(address); } static void SzFree(void *p, void *address) { p = p; MyFree(address); }
@ -203,10 +207,10 @@ static int Decode2( CLzmaDec *state, ISeqOutStream *outStream,
ISeqInStream *inStream, Byte inBuf[], size_t * const inPos, ISeqInStream *inStream, Byte inBuf[], size_t * const inPos,
size_t * const inSize, const int version, const bool testing ) size_t * const inSize, const int version, const bool testing )
{ {
long long total_in = sizeof (File_header), total_out = 0; long long total_in = Fh_size, total_out = 0;
Byte outBuf[OUT_BUF_SIZE]; Byte outBuf[OUT_BUF_SIZE];
size_t outPos = 0; size_t outPos = 0;
uint32_t crc = 0xFFFFFFFF; uint32_t crc = 0xFFFFFFFFU;
LzmaDec_Init(state); LzmaDec_Init(state);
for (;;) for (;;)
{ {
@ -242,7 +246,7 @@ static int Decode2( CLzmaDec *state, ISeqOutStream *outStream,
{ show_error( "data error", 0, false ); return 1; } { show_error( "data error", 0, false ); return 1; }
bool error = false; bool error = false;
File_trailer trailer; File_trailer trailer;
const size_t trailer_size = Ft_size( version ); const size_t trailer_size = Ft_versioned_size( version );
if( *inSize - *inPos < trailer_size && if( *inSize - *inPos < trailer_size &&
!read_inbuf( inStream, inBuf, inPos, inSize ) ) return 1; !read_inbuf( inStream, inBuf, inPos, inSize ) ) return 1;
if( *inSize - *inPos < trailer_size ) if( *inSize - *inPos < trailer_size )
@ -258,13 +262,13 @@ static int Decode2( CLzmaDec *state, ISeqOutStream *outStream,
trailer[i] = inBuf[(*inPos)++]; trailer[i] = inBuf[(*inPos)++];
total_in += trailer_size; total_in += trailer_size;
if( version == 0 ) Ft_set_member_size( trailer, total_in ); if( version == 0 ) Ft_set_member_size( trailer, total_in );
if( Ft_get_data_crc( trailer ) != ( crc ^ 0xFFFFFFFF ) ) if( Ft_get_data_crc( trailer ) != ( crc ^ 0xFFFFFFFFU ) )
{ {
error = true; error = true;
if( verbosity >= 0 ) if( verbosity >= 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",
(unsigned int)Ft_get_data_crc( trailer ), (unsigned int)Ft_get_data_crc( trailer ),
(unsigned int)( crc ^ 0xFFFFFFFF ) ); (unsigned int)( crc ^ 0xFFFFFFFFU ) );
} }
if( Ft_get_data_size( trailer ) != total_out ) if( Ft_get_data_size( trailer ) != total_out )
{ {
@ -305,14 +309,14 @@ static int Decode( ISeqOutStream *outStream, ISeqInStream *inStream,
for( bool first_member = true; ; first_member = false ) for( bool first_member = true; ; first_member = false )
{ {
if( inSize < sizeof (File_header) && if( inSize < Fh_size &&
!read_inbuf( inStream, inBuf, &inPos, &inSize ) ) return 1; !read_inbuf( inStream, inBuf, &inPos, &inSize ) ) return 1;
if( inSize < sizeof (File_header) ) // End Of File if( inSize < Fh_size ) // End Of File
{ {
if( !first_member ) break; if( !first_member ) break;
show_error( "error reading member header", 0, false ); return 1; show_error( "error reading member header", 0, false ); return 1;
} }
for( unsigned int i = 0; i < sizeof (File_header); ++i ) for( int i = 0; i < Fh_size; ++i )
header[i] = inBuf[inPos++]; header[i] = inBuf[inPos++];
if( !Fh_verify_magic( header ) ) if( !Fh_verify_magic( header ) )
{ {
@ -332,7 +336,7 @@ static int Decode( ISeqOutStream *outStream, ISeqInStream *inStream,
Fh_get_dictionary_size( header ) > max_dictionary_size ) Fh_get_dictionary_size( header ) > max_dictionary_size )
{ {
if( verbosity >= 0 ) if( verbosity >= 0 )
fprintf( stderr, "invalid dictionary size in member header" ); fprintf( stderr, "invalid dictionary size in member header.\n" );
return 2; return 2;
} }
@ -345,7 +349,7 @@ static int Decode( ISeqOutStream *outStream, ISeqInStream *inStream,
/* 5 bytes of LZMA properties */ /* 5 bytes of LZMA properties */
unsigned char props[LZMA_PROPS_SIZE]; unsigned char props[LZMA_PROPS_SIZE];
props[0] = 93; // 45 * 2 + 3 props[0] = 93; // (45 * 2) + (9 * 0) + 3
int ds = Fh_get_dictionary_size( header ); int ds = Fh_get_dictionary_size( header );
for( int i = 1; i <= 4; ++i ) { props[i] = ds & 0xFF; ds >>= 8; } for( int i = 1; i <= 4; ++i ) { props[i] = ds & 0xFF; ds >>= 8; }
@ -388,7 +392,7 @@ static int Encode( ISeqOutStream *outStream, ISeqInStream *inStream,
encoder_options->match_len_limit > max_match_len ) encoder_options->match_len_limit > max_match_len )
internal_error( "invalid argument to encoder" ); internal_error( "invalid argument to encoder" );
if( outStream->Write( outStream, header, sizeof (File_header) ) != sizeof (File_header) ) if( outStream->Write( outStream, header, Fh_size ) != Fh_size )
{ show_error( "can not write output file", errno, false ); retval = 1; } { show_error( "can not write output file", errno, false ); retval = 1; }
else else
if( LzmaEnc_Encode(enc, outStream, inStream, NULL, &g_Alloc, &g_Alloc) != 0 ) if( LzmaEnc_Encode(enc, outStream, inStream, NULL, &g_Alloc, &g_Alloc) != 0 )
@ -484,6 +488,7 @@ int main( const int argc, const char * const argv[] )
// to the corresponding LZMA compression modes. // to the corresponding LZMA compression modes.
const struct Lzma_options option_mapping[] = const struct Lzma_options option_mapping[] =
{ {
{ 1 << 16, 5 }, // -0
{ 1 << 20, 10 }, // -1 { 1 << 20, 10 }, // -1
{ 3 << 19, 12 }, // -2 { 3 << 19, 12 }, // -2
{ 1 << 21, 17 }, // -3 { 1 << 21, 17 }, // -3
@ -493,7 +498,7 @@ int main( const int argc, const char * const argv[] )
{ 1 << 24, 108 }, // -7 { 1 << 24, 108 }, // -7
{ 3 << 23, 163 }, // -8 { 3 << 23, 163 }, // -8
{ 1 << 25, 273 } }; // -9 { 1 << 25, 273 } }; // -9
struct Lzma_options encoder_options = option_mapping[5]; // default = "-6" struct Lzma_options encoder_options = option_mapping[6]; // default = "-6"
enum Mode program_mode = m_compress; enum Mode program_mode = m_compress;
bool force = false; bool force = false;
bool keep_input_files = false; bool keep_input_files = false;
@ -505,6 +510,7 @@ int main( const int argc, const char * const argv[] )
const struct ap_Option options[] = const struct ap_Option options[] =
{ {
{ '0', 0, ap_no },
{ '1', "fast", ap_no }, { '1', "fast", ap_no },
{ '2', 0, ap_no }, { '2', 0, ap_no },
{ '3', 0, ap_no }, { '3', 0, ap_no },
@ -517,6 +523,7 @@ int main( const int argc, const char * const argv[] )
{ 'b', "member-size", ap_yes }, { 'b', "member-size", ap_yes },
{ 'c', "stdout", ap_no }, { 'c', "stdout", ap_no },
{ 'd', "decompress", ap_no }, { 'd', "decompress", ap_no },
{ 'e', "extreme", ap_no },
{ 'f', "force", ap_no }, { 'f', "force", ap_no },
{ 'h', "help", ap_no }, { 'h', "help", ap_no },
{ 'k', "keep", ap_no }, { 'k', "keep", ap_no },
@ -544,13 +551,13 @@ int main( const int argc, const char * const argv[] )
if( !code ) break; // no more options if( !code ) break; // no more options
switch( code ) switch( code )
{ {
case '1': case '2': case '3': case '0': case '1': case '2': case '3': case '4':
case '4': case '5': case '6': case '5': case '6': case '7': case '8': case '9':
case '7': case '8': case '9': encoder_options = option_mapping[code-'0']; break;
encoder_options = option_mapping[code-'1']; break;
case 'b': break; case 'b': break;
case 'c': to_stdout = true; break; case 'c': to_stdout = true; break;
case 'd': program_mode = m_decompress; break; case 'd': program_mode = m_decompress; break;
case 'e': break;
case 'f': force = true; break; case 'f': force = true; break;
case 'h': show_help(); return 0; case 'h': show_help(); return 0;
case 'k': keep_input_files = true; break; case 'k': keep_input_files = true; break;

View file

@ -39,7 +39,7 @@ static inline void CRC32_init()
{ {
unsigned int c = n; unsigned int c = n;
for( int k = 0; k < 8; ++k ) for( int k = 0; k < 8; ++k )
{ if( c & 1 ) c = 0xEDB88320 ^ ( c >> 1 ); else c >>= 1; } { if( c & 1 ) c = 0xEDB88320U ^ ( c >> 1 ); else c >>= 1; }
crc32[n] = c; crc32[n] = c;
} }
} }
@ -57,6 +57,7 @@ static inline void CRC32_update_buf( uint32_t * crc, const uint8_t * const buffe
typedef uint8_t File_header[6]; // 0-3 magic bytes typedef uint8_t File_header[6]; // 0-3 magic bytes
// 4 version // 4 version
// 5 coded_dict_size; // 5 coded_dict_size;
enum { Fh_size = 6 };
static inline void Fh_set_magic( File_header header ) static inline void Fh_set_magic( File_header header )
{ {
@ -87,23 +88,23 @@ static inline int Fh_real_bits( const int value )
static inline int Fh_get_dictionary_size( const File_header header ) static inline int Fh_get_dictionary_size( const File_header header )
{ {
int size = ( 1 << ( header[5] & 0x1F ) ); int sz = ( 1 << ( header[5] & 0x1F ) );
if( size > min_dictionary_size && size <= max_dictionary_size ) if( sz > min_dictionary_size && sz <= max_dictionary_size )
size -= ( size / 16 ) * ( ( header[5] >> 5 ) & 0x07 ); sz -= ( sz / 16 ) * ( ( header[5] >> 5 ) & 0x07 );
return size; return sz;
} }
static inline bool Fh_set_dictionary_size( File_header header, const int size ) static inline bool Fh_set_dictionary_size( File_header header, const int sz )
{ {
if( size >= min_dictionary_size && size <= max_dictionary_size ) if( sz >= min_dictionary_size && sz <= max_dictionary_size )
{ {
header[5] = Fh_real_bits( size - 1 ); header[5] = Fh_real_bits( sz - 1 );
if( size > min_dictionary_size ) if( sz > min_dictionary_size )
{ {
const int base_size = 1 << header[5]; const int base_size = 1 << header[5];
const int wedge = base_size / 16; const int wedge = base_size / 16;
for( int i = 7; i >= 1; --i ) for( int i = 7; i >= 1; --i )
if( base_size - ( i * wedge ) >= size ) if( base_size - ( i * wedge ) >= sz )
{ header[5] |= ( i << 5 ); break; } { header[5] |= ( i << 5 ); break; }
} }
return true; return true;
@ -117,8 +118,10 @@ typedef uint8_t File_trailer[20];
// 4-11 size of the uncompressed data // 4-11 size of the uncompressed data
// 12-19 member size including header and trailer // 12-19 member size including header and trailer
static inline int Ft_size( const int version ) enum { Ft_size = 20 };
{ return sizeof (File_trailer) - ( ( version >= 1 ) ? 0 : 8 ); }
static inline int Ft_versioned_size( const int version )
{ return ( ( version >= 1 ) ? 20 : 12 ); }
static inline uint32_t Ft_get_data_crc( const File_trailer trailer ) static inline uint32_t Ft_get_data_crc( const File_trailer trailer )
{ {
@ -137,9 +140,9 @@ static inline long long Ft_get_data_size( const File_trailer trailer )
return tmp; return tmp;
} }
static inline void Ft_set_data_size( File_trailer trailer, long long size ) static inline void Ft_set_data_size( File_trailer trailer, long long sz )
{ {
for( int i = 4; i <= 11; ++i ) { trailer[i] = (uint8_t)size; size >>= 8; } for( int i = 4; i <= 11; ++i ) { trailer[i] = (uint8_t)sz; sz >>= 8; }
} }
static inline long long Ft_get_member_size( const File_trailer trailer ) static inline long long Ft_get_member_size( const File_trailer trailer )
@ -149,9 +152,9 @@ static inline long long Ft_get_member_size( const File_trailer trailer )
return tmp; return tmp;
} }
static inline void Ft_set_member_size( File_trailer trailer, long long size ) static inline void Ft_set_member_size( File_trailer trailer, long long sz )
{ {
for( int i = 12; i <= 19; ++i ) { trailer[i] = (uint8_t)size; size >>= 8; } for( int i = 12; i <= 19; ++i ) { trailer[i] = (uint8_t)sz; sz >>= 8; }
} }

View file

@ -28,7 +28,7 @@ fail=0
"${LZIP}" -cd "${testdir}"/test1.lz > copy || fail=1 "${LZIP}" -cd "${testdir}"/test1.lz > copy || fail=1
cmp in copy || fail=1 cmp in copy || fail=1
for i in s4Ki 1 2 3 4 5 6 7 ; do for i in s4Ki 0 1 2 3 4 5 6 7 ; do
"${LZIP}" -k -$i in || fail=1 "${LZIP}" -k -$i in || fail=1
mv -f in.lz copy.lz || fail=1 mv -f in.lz copy.lz || fail=1
printf "garbage" >> copy.lz || fail=1 printf "garbage" >> copy.lz || fail=1
@ -37,7 +37,7 @@ for i in s4Ki 1 2 3 4 5 6 7 ; do
printf . printf .
done done
for i in s4Ki 1 2 3 4 5 6 7 ; do for i in s4Ki 0 1 2 3 4 5 6 7 ; do
"${LZIP}" -c -$i in > out || fail=1 "${LZIP}" -c -$i in > out || fail=1
printf "g" >> out || fail=1 printf "g" >> out || fail=1
"${LZIP}" -cd out > copy || fail=1 "${LZIP}" -cd out > copy || fail=1
@ -45,7 +45,7 @@ for i in s4Ki 1 2 3 4 5 6 7 ; do
printf . printf .
done done
for i in s4Ki 1 2 3 4 5 6 7 ; do for i in s4Ki 0 1 2 3 4 5 6 7 ; do
"${LZIP}" -$i < in > out || fail=1 "${LZIP}" -$i < in > out || fail=1
"${LZIP}" -d < out > copy || fail=1 "${LZIP}" -d < out > copy || fail=1
cmp in copy || fail=1 cmp in copy || fail=1