summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 14:22:39 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 14:22:39 +0000
commit9ce00d8c30fb636d64b1279eb591ac97a43417f4 (patch)
treeb719a67c2e69edd3a612035ab89d70f52e0df147
parentAdding debian version 1.0~rc2-1. (diff)
downloadpdlzip-9ce00d8c30fb636d64b1279eb591ac97a43417f4.tar.xz
pdlzip-9ce00d8c30fb636d64b1279eb591ac97a43417f4.zip
Merging upstream version 1.0~rc3.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-rw-r--r--ChangeLog5
-rw-r--r--LzFind.c2
-rw-r--r--LzmaEnc.c8
-rwxr-xr-xconfigure4
-rw-r--r--doc/pdlzip.12
-rw-r--r--main.c39
-rw-r--r--pdlzip.h35
-rwxr-xr-xtestsuite/check.sh6
8 files changed, 58 insertions, 43 deletions
diff --git a/ChangeLog b/ChangeLog
index 2d56d55..e1af453 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* Version 1.0-rc2 released.
diff --git a/LzFind.c b/LzFind.c
index 98e5091..bec8b3e 100644
--- a/LzFind.c
+++ b/LzFind.c
@@ -141,7 +141,7 @@ void MatchFinder_Construct(CMatchFinder *p)
p->directInput = 0;
p->hash = 0;
MatchFinder_SetDefaultSettings(p);
- p->crc = 0xFFFFFFFF;
+ p->crc = 0xFFFFFFFFU;
}
static void MatchFinder_FreeThisClassMemory(CMatchFinder *p, ISzAlloc *alloc)
diff --git a/LzmaEnc.c b/LzmaEnc.c
index 235b07e..dfba154 100644
--- a/LzmaEnc.c
+++ b/LzmaEnc.c
@@ -1574,15 +1574,15 @@ static void LZe_full_flush(CLzmaEnc *p, UInt32 posState)
RangeEnc_FlushData(&p->rc);
RangeEnc_FlushStream(&p->rc);
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_member_size( trailer, p->rc.processed + sizeof (File_header) + sizeof (File_trailer) );
- if( p->rc.outStream->Write( p->rc.outStream, trailer, sizeof (File_trailer)) != sizeof (File_trailer))
+ Ft_set_member_size( trailer, p->rc.processed + Fh_size + Ft_size );
+ if( p->rc.outStream->Write( p->rc.outStream, trailer, Ft_size ) != Ft_size )
p->rc.res = SZ_ERROR_WRITE;
if( verbosity >= 1 )
{
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 )
fprintf( stderr, "no data compressed.\n" );
else
diff --git a/configure b/configure
index b4ade29..67e77cb 100755
--- a/configure
+++ b/configure
@@ -5,12 +5,12 @@
# This configure script is free software: you have unlimited permission
# to copy, distribute and modify it.
#
-# Date of this version: 2010-02-27
+# Date of this version: 2010-03-14
args=
no_create=
pkgname=pdlzip
-pkgversion=1.0-rc2
+pkgversion=1.0-rc3
progname=pdlzip
srctrigger=pdlzip.h
diff --git a/doc/pdlzip.1 b/doc/pdlzip.1
index 695925b..2101880 100644
--- a/doc/pdlzip.1
+++ b/doc/pdlzip.1
@@ -1,5 +1,5 @@
.\" 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
Pdlzip \- data compressor based on the LZMA algorithm
.SH SYNOPSIS
diff --git a/main.c b/main.c
index 2674285..d82fd91 100644
--- a/main.c
+++ b/main.c
@@ -28,6 +28,10 @@
#include "LzmaDec.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 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,
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];
size_t outPos = 0;
- uint32_t crc = 0xFFFFFFFF;
+ uint32_t crc = 0xFFFFFFFFU;
LzmaDec_Init(state);
for (;;)
{
@@ -242,7 +246,7 @@ static int Decode2( CLzmaDec *state, ISeqOutStream *outStream,
{ show_error( "data error", 0, false ); return 1; }
bool error = false;
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 &&
!read_inbuf( inStream, inBuf, inPos, inSize ) ) return 1;
if( *inSize - *inPos < trailer_size )
@@ -258,13 +262,13 @@ static int Decode2( CLzmaDec *state, ISeqOutStream *outStream,
trailer[i] = inBuf[(*inPos)++];
total_in += trailer_size;
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;
if( verbosity >= 0 )
fprintf( stderr, "crc mismatch; trailer says %08X, data crc is %08X.\n",
(unsigned int)Ft_get_data_crc( trailer ),
- (unsigned int)( crc ^ 0xFFFFFFFF ) );
+ (unsigned int)( crc ^ 0xFFFFFFFFU ) );
}
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 )
{
- if( inSize < sizeof (File_header) &&
+ if( inSize < Fh_size &&
!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;
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++];
if( !Fh_verify_magic( header ) )
{
@@ -332,7 +336,7 @@ static int Decode( ISeqOutStream *outStream, ISeqInStream *inStream,
Fh_get_dictionary_size( header ) > max_dictionary_size )
{
if( verbosity >= 0 )
- fprintf( stderr, "invalid dictionary size in member header" );
+ fprintf( stderr, "invalid dictionary size in member header.\n" );
return 2;
}
@@ -345,7 +349,7 @@ static int Decode( ISeqOutStream *outStream, ISeqInStream *inStream,
/* 5 bytes of LZMA properties */
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 );
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 )
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; }
else
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.
const struct Lzma_options option_mapping[] =
{
+ { 1 << 16, 5 }, // -0
{ 1 << 20, 10 }, // -1
{ 3 << 19, 12 }, // -2
{ 1 << 21, 17 }, // -3
@@ -493,7 +498,7 @@ int main( const int argc, const char * const argv[] )
{ 1 << 24, 108 }, // -7
{ 3 << 23, 163 }, // -8
{ 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;
bool force = false;
bool keep_input_files = false;
@@ -505,6 +510,7 @@ int main( const int argc, const char * const argv[] )
const struct ap_Option options[] =
{
+ { '0', 0, ap_no },
{ '1', "fast", ap_no },
{ '2', 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 },
{ 'c', "stdout", ap_no },
{ 'd', "decompress", ap_no },
+ { 'e', "extreme", ap_no },
{ 'f', "force", ap_no },
{ 'h', "help", 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
switch( code )
{
- case '1': case '2': case '3':
- case '4': case '5': case '6':
- case '7': case '8': case '9':
- encoder_options = option_mapping[code-'1']; break;
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ encoder_options = option_mapping[code-'0']; break;
case 'b': break;
case 'c': to_stdout = true; break;
case 'd': program_mode = m_decompress; break;
+ case 'e': break;
case 'f': force = true; break;
case 'h': show_help(); return 0;
case 'k': keep_input_files = true; break;
diff --git a/pdlzip.h b/pdlzip.h
index 604f508..5af155b 100644
--- a/pdlzip.h
+++ b/pdlzip.h
@@ -39,7 +39,7 @@ static inline void CRC32_init()
{
unsigned int c = n;
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;
}
}
@@ -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
// 4 version
// 5 coded_dict_size;
+enum { Fh_size = 6 };
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 )
{
- int size = ( 1 << ( header[5] & 0x1F ) );
- if( size > min_dictionary_size && size <= max_dictionary_size )
- size -= ( size / 16 ) * ( ( header[5] >> 5 ) & 0x07 );
- return size;
+ int sz = ( 1 << ( header[5] & 0x1F ) );
+ if( sz > min_dictionary_size && sz <= max_dictionary_size )
+ sz -= ( sz / 16 ) * ( ( header[5] >> 5 ) & 0x07 );
+ 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 );
- if( size > min_dictionary_size )
+ header[5] = Fh_real_bits( sz - 1 );
+ if( sz > min_dictionary_size )
{
const int base_size = 1 << header[5];
const int wedge = base_size / 16;
for( int i = 7; i >= 1; --i )
- if( base_size - ( i * wedge ) >= size )
+ if( base_size - ( i * wedge ) >= sz )
{ header[5] |= ( i << 5 ); break; }
}
return true;
@@ -117,8 +118,10 @@ typedef uint8_t File_trailer[20];
// 4-11 size of the uncompressed data
// 12-19 member size including header and trailer
-static inline int Ft_size( const int version )
- { return sizeof (File_trailer) - ( ( version >= 1 ) ? 0 : 8 ); }
+enum { Ft_size = 20 };
+
+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 )
{
@@ -137,9 +140,9 @@ static inline long long Ft_get_data_size( const File_trailer trailer )
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 )
@@ -149,9 +152,9 @@ static inline long long Ft_get_member_size( const File_trailer trailer )
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; }
}
diff --git a/testsuite/check.sh b/testsuite/check.sh
index 014bc31..d179a3c 100755
--- a/testsuite/check.sh
+++ b/testsuite/check.sh
@@ -28,7 +28,7 @@ fail=0
"${LZIP}" -cd "${testdir}"/test1.lz > 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
mv -f in.lz 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 .
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
printf "g" >> out || 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 .
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}" -d < out > copy || fail=1
cmp in copy || fail=1