From a85a8dd94a47e952df1b8e77cdbf0de614e9e3c3 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 30 Nov 2015 11:53:11 +0100 Subject: [PATCH] Fixed #80 (reported by @luben) Added : tests for ZSTD_LEGACY=disable build mode extended ZSTD_LEGACY=disable to dll build --- .travis.yml | 1 + NEWS | 5 ++++- lib/Makefile | 15 ++++++++++++--- programs/Makefile | 6 ++++++ programs/fileio.c | 22 +++++++++------------- 5 files changed, 32 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index 83a6f23a..846f1217 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,7 @@ env: - ZSTD_TRAVIS_CI_ENV=armtest - ZSTD_TRAVIS_CI_ENV=test - ZSTD_TRAVIS_CI_ENV="-C programs test32" + - ZSTD_TRAVIS_CI_ENV="-C programs test-zstd_nolegacy" - ZSTD_TRAVIS_CI_ENV=usan - ZSTD_TRAVIS_CI_ENV=asan - ZSTD_TRAVIS_CI_ENV="-C programs valgrindTest" diff --git a/NEWS b/NEWS index 75c9b87e..30d64424 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ +v0.4.1 +Fixed : ZSTD_LEGACY=disable build mode (reported by Luben) + v0.4.0 -Command line utility is now compatible with high compression levels +Command line utility compatible with high compression levels Removed zstdhc => merged into zstd Added : ZBUFF API (see zstd_buffered.h) Rolling buffer support diff --git a/lib/Makefile b/lib/Makefile index 3e34d896..eedd3d95 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -40,7 +40,7 @@ VERSION?= $(LIBVER) DESTDIR?= PREFIX ?= /usr/local -CPPFLAGS= -I. -I./legacy -DZSTD_LEGACY_SUPPORT=1 +CPPFLAGS= -I. CFLAGS ?= -O3 CFLAGS += -std=c99 -Wall -Wextra -Wundef -Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MOREFLAGS) @@ -48,6 +48,16 @@ FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MOREFLAGS) LIBDIR ?= $(PREFIX)/lib INCLUDEDIR=$(PREFIX)/include +ZSTD_FILES := zstd_compress.c zstd_decompress.c fse.c huff0.c +ZSTD_LEGACY:= legacy/zstd_v01.c legacy/zstd_v02.c legacy/zstd_v03.c + +ifeq ($(ZSTD_LEGACY),disable) +CPPFLAGS += -DZSTD_LEGACY_SUPPORT=0 +else +ZSTD_FILES+= $(ZSTD_LEGACY) +CPPFLAGS += -I./legacy -DZSTD_LEGACY_SUPPORT=1 +endif + # OS X linker doesn't support -soname, and use different extension # see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html @@ -70,8 +80,7 @@ default: clean libzstd all: clean libzstd -libzstd: zstd_compress.c zstd_decompress.c huff0.c fse.c \ - legacy/zstd_v01.c legacy/zstd_v02.c legacy/zstd_v03.c +libzstd: $(ZSTD_FILES) @echo compiling static library @$(CC) $(FLAGS) -c $^ @$(AR) rcs libzstd.a *.o diff --git a/programs/Makefile b/programs/Makefile index 9d73cb95..1ff9c6fa 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -80,6 +80,9 @@ zstd32: $(ZSTD_FILES) $(ZSTDDIR)/zstd_buffered.c \ xxhash.c bench.c fileio.c zstdcli.c $(ZSTD_FILEIO_LEGACY) $(CC) -m32 $(FLAGS) $^ -o $@$(EXT) +zstd_nolegacy : + $(MAKE) zstd ZSTD_LEGACY=disable + fullbench : $(ZSTD_FILES) \ datagen.c fullbench.c $(CC) $(FLAGS) $^ -o $@$(EXT) @@ -230,6 +233,9 @@ test-zstd: zstd zstd-playTests test-zstd32: ZSTD = ./zstd32 test-zstd32: zstd32 zstd-playTests +test-zstd_nolegacy: ZSTD = ./zstd +test-zstd_nolegacy: zstd_nolegacy zstd-playTests + test-fullbench: fullbench datagen ./fullbench -i1 ./fullbench -i1 -P0 diff --git a/programs/fileio.c b/programs/fileio.c index e84d6332..27c72c57 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -382,21 +382,17 @@ unsigned long long FIO_decompressFilename(const char* output_filename, const cha /* for each frame */ for ( ; ; ) { - toRead = 0; - + size_t sizeCheck; + /* check magic number -> version */ + toRead = 4; + sizeCheck = fread(inBuff, (size_t)1, toRead, finput); + if (sizeCheck==0) break; /* no more input */ + if (sizeCheck != toRead) EXM_THROW(31, "Read error : cannot read header"); #if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT==1) + if (ZSTD_isLegacy(MEM_readLE32(inBuff))) { - size_t sizeCheck; - /* check magic number -> version */ - toRead = 4; - sizeCheck = fread(inBuff, (size_t)1, toRead, finput); - if (sizeCheck==0) break; /* no more input */ - if (sizeCheck != toRead) EXM_THROW(31, "Read error : cannot read header"); - if (ZSTD_isLegacy(MEM_readLE32(inBuff))) - { - filesize += FIO_decompressLegacyFrame(foutput, finput, MEM_readLE32(inBuff)); - continue; - } + filesize += FIO_decompressLegacyFrame(foutput, finput, MEM_readLE32(inBuff)); + continue; } #endif /* ZSTD_LEGACY_SUPPORT */