lz4.c : corrected issue 98 within LZ4_compress_limitedOutput()

Makefile : can specify version number

git-svn-id: https://lz4.googlecode.com/svn/trunk@109 650e7d94-2a16-8b24-b05c-7c0b3f6821cd
This commit is contained in:
yann.collet.73@gmail.com 2013-12-03 15:50:46 +00:00
parent 7a863abfc2
commit 8ac549f10a
6 changed files with 26 additions and 16 deletions

View File

@ -30,14 +30,14 @@
# fullbench32: Same as fullbench, but forced to compile in 32-bits mode
# ################################################################
RELEASE=r108
RELEASE=r109
DESTDIR=
PREFIX=${DESTDIR}/usr
BINDIR=$(PREFIX)/bin
MANDIR=$(PREFIX)/share/man/man1
DISTRIBNAME=lz4-$(RELEASE).tar.gz
CC=gcc
CFLAGS=-I. -std=c99 -Wall -W -Wundef
CFLAGS=-I. -std=c99 -Wall -W -Wundef -DLZ4_VERSION=\"v1.0.9\"
# Define *.exe as extension for Windows systems
# ifeq ($(OS),Windows_NT)

4
NEWS
View File

@ -1,3 +1,7 @@
r109 :
lz4.c : corrected issue 98 (LZ4_compress_limitedOutput())
Makefile : can specify version number from makefile
r108 :
lz4.c : corrected compression efficiency issue 97 in 64-bits chained mode (-BD) for streams > 4 GB (thanks Roman Strashkin for reporting)

View File

@ -103,11 +103,12 @@
//****************************
// Constants
//****************************
#define COMPRESSOR_NAME "LZ4 speed analyzer"
#define COMPRESSOR_VERSION ""
#define COMPILED __DATE__
#define PROGRAM_DESCRIPTION "LZ4 speed analyzer"
#ifndef LZ4_VERSION
# define LZ4_VERSION ""
#endif
#define AUTHOR "Yann Collet"
#define WELCOME_MESSAGE "*** %s %s %i-bits, by %s (%s) ***\n", COMPRESSOR_NAME, COMPRESSOR_VERSION, (int)(sizeof(void*)*8), AUTHOR, COMPILED
#define WELCOME_MESSAGE "*** %s %s %i-bits, by %s (%s) ***\n", PROGRAM_DESCRIPTION, LZ4_VERSION, (int)(sizeof(void*)*8), AUTHOR, __DATE__
#define NBLOOPS 6
#define TIMELOOP 2500

View File

@ -42,6 +42,10 @@
//**************************************
// Constants
//**************************************
#ifndef LZ4_VERSION
# define LZ4_VERSION ""
#endif
#define NB_ATTEMPTS (1<<17)
#define LEN ((1<<15))
#define SEQ_POW 2
@ -135,7 +139,7 @@ int main() {
# define FUZ_CHECKTEST(cond, message) if (cond) { printf("Test %i : %s : seed %u, cycle %i \n", testNb, message, seed, attemptNb); goto _output_error; }
# define FUZ_DISPLAYTEST testNb++; printf("%2i\b\b", testNb);
printf("starting LZ4 fuzzer\n");
printf("starting LZ4 fuzzer (%s)\n", LZ4_VERSION);
printf("Select an Initialisation number (default : random) : ");
fflush(stdout);
if ( fgets(userInput, sizeof userInput, stdin) )

12
lz4.c
View File

@ -469,7 +469,7 @@ FORCE_INLINE int LZ4_compress_generic(
// Encode Literal length
length = (int)(ip - anchor);
token = op++;
if ((limitedOutput) && unlikely(op + length + (2 + 1 + LASTLITERALS) + (length>>8) > oend)) return 0; // Check output limit
if ((limitedOutput) && unlikely(op + length + (2 + 1 + LASTLITERALS) + (length/255) > oend)) return 0; // Check output limit
if (length>=(int)RUN_MASK)
{
int len = length-RUN_MASK;
@ -534,7 +534,7 @@ _last_literals:
// Encode Last Literals
{
int lastRun = (int)(iend - anchor);
if ((limitedOutput) && (((char*)op - dest) + lastRun + 1 + ((lastRun+255-RUN_MASK)/255) > (U32)maxOutputSize)) return 0; // Check output limit
if ((limitedOutput) && (((char*)op - dest) + lastRun + 1 + ((lastRun+255-RUN_MASK)/255) > (U32)maxOutputSize)) return 0; // Check output limit
if (lastRun>=(int)RUN_MASK) { *op++=(RUN_MASK<<ML_BITS); lastRun-=RUN_MASK; for(; lastRun >= 255 ; lastRun-=255) *op++ = 255; *op++ = (BYTE) lastRun; }
else *op++ = (BYTE)(lastRun<<ML_BITS);
memcpy(op, anchor, iend - anchor);
@ -648,10 +648,10 @@ char* LZ4_slideInputBuffer (void* LZ4_Data)
}
else
{
memcpy((void*)(lz4ds->bufferStart), (const void*)(lz4ds->nextBlock - 64 KB), 64 KB);
lz4ds->nextBlock -= delta;
lz4ds->base -= delta;
}
memcpy((void*)(lz4ds->bufferStart), (const void*)(lz4ds->nextBlock - 64 KB), 64 KB);
lz4ds->nextBlock -= delta;
lz4ds->base -= delta;
}
return (char*)(lz4ds->nextBlock);
}

View File

@ -107,11 +107,12 @@
// Constants
//****************************
#define COMPRESSOR_NAME "LZ4 Compression CLI"
#define COMPRESSOR_VERSION "v1.0.8"
#define COMPILED __DATE__
#ifndef LZ4_VERSION
# define LZ4_VERSION "v1.0.9"
#endif
#define AUTHOR "Yann Collet"
#define WELCOME_MESSAGE "*** %s %i-bits %s, by %s (%s) ***\n", COMPRESSOR_NAME, (int)(sizeof(void*)*8), LZ4_VERSION, AUTHOR, __DATE__
#define LZ4_EXTENSION ".lz4"
#define WELCOME_MESSAGE "*** %s %i-bits %s, by %s (%s) ***\n", COMPRESSOR_NAME, (int)(sizeof(void*)*8), COMPRESSOR_VERSION, AUTHOR, COMPILED
#define KB *(1U<<10)
#define MB *(1U<<20)