From a4ca246ecae023469a6c93c0c274f2bc97d7103f Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Sat, 14 Sep 2019 20:15:35 +0300 Subject: [PATCH 01/11] build/cmake/README.md: improve --- build/cmake/README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/build/cmake/README.md b/build/cmake/README.md index 854389ad..73b30dc7 100644 --- a/build/cmake/README.md +++ b/build/cmake/README.md @@ -5,9 +5,9 @@ use case sensitivity that matches modern (ie. cmake version 2.6 and above) conventions of using lower-case for commands, and upper-case for variables. -# How to build +## How to build -As cmake doesn't support command like `cmake clean`, it's recommanded to perform a "out of source build". +As cmake doesn't support command like `cmake clean`, it's recommended to perform a "out of source build". To do this, you can create a new directory and build in it: ```sh cd build/cmake @@ -16,7 +16,7 @@ cd builddir cmake .. make ``` -Then you can clean all cmake caches by simpily delete the new directory: +Then you can clean all cmake caches by simply delete the new directory: ```sh rm -rf build/cmake/builddir ``` @@ -34,19 +34,19 @@ cd build/cmake/builddir cmake -LH .. ``` -Bool options can be set to ON/OFF with -D\[option\]=\[ON/OFF\]. You can configure cmake options like this: +Bool options can be set to `ON/OFF` with `-D[option]=[ON/OFF]`. You can configure cmake options like this: ```sh cd build/cmake/builddir cmake -DZSTD_BUILD_TESTS=ON -DZSTD_LEGACY_SUPPORT=ON .. make ``` -## referring +### referring [Looking for a 'cmake clean' command to clear up CMake output](https://stackoverflow.com/questions/9680420/looking-for-a-cmake-clean-command-to-clear-up-cmake-output) -# CMake Style Recommendations +## CMake Style Recommendations -## Indent all code correctly, i.e. the body of +### Indent all code correctly, i.e. the body of * if/else/endif * foreach/endforeach @@ -57,7 +57,7 @@ make Use spaces for indenting, 2, 3 or 4 spaces preferably. Use the same amount of spaces for indenting as is used in the rest of the file. Do not use tabs. -## Upper/lower casing +### Upper/lower casing Most important: use consistent upper- or lowercasing within one file ! @@ -77,7 +77,7 @@ Add_Executable(hello hello.c) aDd_ExEcUtAbLe(blub blub.c) ``` -## End commands +### End commands To make the code easier to read, use empty commands for endforeach(), endif(), endfunction(), endmacro() and endwhile(). Also, use empty else() commands. @@ -99,6 +99,6 @@ if(BARVAR) endif(BARVAR) ``` -## Other resources for best practices +### Other resources for best practices -`https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#modules` +https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#modules From b804dd3e5bd3397fa5bbb3a5313496e9156d4fb5 Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Sat, 14 Sep 2019 21:14:43 +0300 Subject: [PATCH 02/11] #754 move sufixlist upper and improve error message on missing suffix --- programs/fileio.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/programs/fileio.c b/programs/fileio.c index 8a45563d..e5fb1aad 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -2169,12 +2169,24 @@ FIO_determineDstName(const char* srcFileName) static size_t dfnbCapacity = 0; static char* dstFileNameBuffer = NULL; /* using static allocation : this function cannot be multi-threaded */ + const char* suffixlist = ZSTD_EXTENSION + #ifdef ZSTD_GZDECOMPRESS + "/" GZ_EXTENSION + #endif + #ifdef ZSTD_LZMADECOMPRESS + "/" XZ_EXTENSION "/" LZMA_EXTENSION + #endif + #ifdef ZSTD_LZ4DECOMPRESS + "/" LZ4_EXTENSION + #endif + ; + size_t const sfnSize = strlen(srcFileName); size_t suffixSize; const char* const suffixPtr = strrchr(srcFileName, '.'); if (suffixPtr == NULL) { - DISPLAYLEVEL(1, "zstd: %s: unknown suffix -- ignored \n", - srcFileName); + DISPLAYLEVEL(1, "zstd: %s: missing suffix (%s expected) -- ignored \n", + srcFileName, suffixlist); return NULL; } suffixSize = strlen(suffixPtr); @@ -2193,17 +2205,6 @@ FIO_determineDstName(const char* srcFileName) && strcmp(suffixPtr, LZ4_EXTENSION) #endif ) ) { - const char* suffixlist = ZSTD_EXTENSION - #ifdef ZSTD_GZDECOMPRESS - "/" GZ_EXTENSION - #endif - #ifdef ZSTD_LZMADECOMPRESS - "/" XZ_EXTENSION "/" LZMA_EXTENSION - #endif - #ifdef ZSTD_LZ4DECOMPRESS - "/" LZ4_EXTENSION - #endif - ; DISPLAYLEVEL(1, "zstd: %s: unknown suffix (%s expected) -- ignored \n", srcFileName, suffixlist); return NULL; From 8cc815a941d2b96a867a4c3d89af3b4cd574d0e8 Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Sat, 14 Sep 2019 21:15:24 +0300 Subject: [PATCH 03/11] #754 sufixlist->SUFFIX_LIST --- programs/fileio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/programs/fileio.c b/programs/fileio.c index e5fb1aad..7ad54055 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -2169,7 +2169,7 @@ FIO_determineDstName(const char* srcFileName) static size_t dfnbCapacity = 0; static char* dstFileNameBuffer = NULL; /* using static allocation : this function cannot be multi-threaded */ - const char* suffixlist = ZSTD_EXTENSION + const char* SUFFIX_LIST = ZSTD_EXTENSION #ifdef ZSTD_GZDECOMPRESS "/" GZ_EXTENSION #endif @@ -2186,7 +2186,7 @@ FIO_determineDstName(const char* srcFileName) const char* const suffixPtr = strrchr(srcFileName, '.'); if (suffixPtr == NULL) { DISPLAYLEVEL(1, "zstd: %s: missing suffix (%s expected) -- ignored \n", - srcFileName, suffixlist); + srcFileName, SUFFIX_LIST); return NULL; } suffixSize = strlen(suffixPtr); @@ -2206,7 +2206,7 @@ FIO_determineDstName(const char* srcFileName) #endif ) ) { DISPLAYLEVEL(1, "zstd: %s: unknown suffix (%s expected) -- ignored \n", - srcFileName, suffixlist); + srcFileName, SUFFIX_LIST); return NULL; } From 7d9cd22e2145f68cb04b87d76907366726ab0bc3 Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Sat, 14 Sep 2019 21:23:47 +0300 Subject: [PATCH 04/11] #754 Add a hint about -o option --- programs/fileio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/programs/fileio.c b/programs/fileio.c index 7ad54055..edf58fee 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -2185,7 +2185,7 @@ FIO_determineDstName(const char* srcFileName) size_t suffixSize; const char* const suffixPtr = strrchr(srcFileName, '.'); if (suffixPtr == NULL) { - DISPLAYLEVEL(1, "zstd: %s: missing suffix (%s expected) -- ignored \n", + DISPLAYLEVEL(1, "zstd: %s: missing suffix (%s expected). Can't derive the output file name so specify it with -o dstFileName. -- ignored \n", srcFileName, SUFFIX_LIST); return NULL; } @@ -2205,7 +2205,7 @@ FIO_determineDstName(const char* srcFileName) && strcmp(suffixPtr, LZ4_EXTENSION) #endif ) ) { - DISPLAYLEVEL(1, "zstd: %s: unknown suffix (%s expected) -- ignored \n", + DISPLAYLEVEL(1, "zstd: %s: unknown suffix (%s expected). Can't derive the output file name so specify it with -o dstFileName. -- ignored \n", srcFileName, SUFFIX_LIST); return NULL; } From a101721f4e2f3cfa0296b5b61147f272e77c8b68 Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Sat, 14 Sep 2019 21:26:27 +0300 Subject: [PATCH 05/11] Use one strstr() call instead of chain of strcmp() --- programs/fileio.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/programs/fileio.c b/programs/fileio.c index edf58fee..8816115b 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -2193,18 +2193,7 @@ FIO_determineDstName(const char* srcFileName) /* check suffix is authorized */ if (sfnSize <= suffixSize - || ( strcmp(suffixPtr, ZSTD_EXTENSION) - #ifdef ZSTD_GZDECOMPRESS - && strcmp(suffixPtr, GZ_EXTENSION) - #endif - #ifdef ZSTD_LZMADECOMPRESS - && strcmp(suffixPtr, XZ_EXTENSION) - && strcmp(suffixPtr, LZMA_EXTENSION) - #endif - #ifdef ZSTD_LZ4DECOMPRESS - && strcmp(suffixPtr, LZ4_EXTENSION) - #endif - ) ) { + || (strstr(SUFFIX_LIST, suffixPtr) == NULL)) { DISPLAYLEVEL(1, "zstd: %s: unknown suffix (%s expected). Can't derive the output file name so specify it with -o dstFileName. -- ignored \n", srcFileName, SUFFIX_LIST); return NULL; From 59f369a6da86e83948084270a06ad72368f079cc Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Sat, 14 Sep 2019 21:30:15 +0300 Subject: [PATCH 06/11] Add short tar's extensions .tgz (.tar.gz), .txz (.tar.xz), .tzst (.tar.zst) --- programs/fileio.c | 8 ++++---- programs/fileio.h | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/programs/fileio.c b/programs/fileio.c index 8816115b..f7e3b234 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -2169,15 +2169,15 @@ FIO_determineDstName(const char* srcFileName) static size_t dfnbCapacity = 0; static char* dstFileNameBuffer = NULL; /* using static allocation : this function cannot be multi-threaded */ - const char* SUFFIX_LIST = ZSTD_EXTENSION + const char* SUFFIX_LIST = ZSTD_EXTENSION "/" TZSTD_EXTENSION #ifdef ZSTD_GZDECOMPRESS - "/" GZ_EXTENSION + "/" GZ_EXTENSION "/" TGZ_EXTENSION #endif #ifdef ZSTD_LZMADECOMPRESS - "/" XZ_EXTENSION "/" LZMA_EXTENSION + "/" XZ_EXTENSION "/" LZMA_EXTENSION "/" TXZ_EXTENSION #endif #ifdef ZSTD_LZ4DECOMPRESS - "/" LZ4_EXTENSION + "/" LZ4_EXTENSION "/" TLZ4_EXTENSION #endif ; diff --git a/programs/fileio.h b/programs/fileio.h index 096d90b5..ebd2ffbe 100644 --- a/programs/fileio.h +++ b/programs/fileio.h @@ -32,9 +32,13 @@ extern "C" { #endif #define LZMA_EXTENSION ".lzma" #define XZ_EXTENSION ".xz" +#define TXZ_EXTENSION ".txz" #define GZ_EXTENSION ".gz" +#define TGZ_EXTENSION ".tgz" #define ZSTD_EXTENSION ".zst" +#define TZSTD_EXTENSION ".tzst" #define LZ4_EXTENSION ".lz4" +#define TLZ4_EXTENSION ".tlz4" /*-************************************* From bfb4d830b299feb14da189b775700b5fa41950d5 Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Wed, 18 Sep 2019 09:21:00 +0300 Subject: [PATCH 07/11] FIO_determineDstName: extract dstFileNameEndPos variable --- programs/fileio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/programs/fileio.c b/programs/fileio.c index f7e3b234..96170b14 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -2210,8 +2210,9 @@ FIO_determineDstName(const char* srcFileName) /* return dst name == src name truncated from suffix */ assert(dstFileNameBuffer != NULL); - memcpy(dstFileNameBuffer, srcFileName, sfnSize - suffixSize); - dstFileNameBuffer[sfnSize-suffixSize] = '\0'; + size_t dstFileNameEndPos = sfnSize - suffixSize; + memcpy(dstFileNameBuffer, srcFileName, dstFileNameEndPos); + dstFileNameBuffer[dstFileNameEndPos] = '\0'; return dstFileNameBuffer; /* note : dstFileNameBuffer memory is not going to be free */ From dafe796e39492a180dacec35b4a4c963dcd88a37 Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Wed, 18 Sep 2019 09:23:10 +0300 Subject: [PATCH 08/11] #1790 short tar's extensions tgz, txz, tlz4m .tzst should be decompressed with .tar suffix --- programs/fileio.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/programs/fileio.c b/programs/fileio.c index 96170b14..5aaad0e9 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -2212,6 +2212,15 @@ FIO_determineDstName(const char* srcFileName) assert(dstFileNameBuffer != NULL); size_t dstFileNameEndPos = sfnSize - suffixSize; memcpy(dstFileNameBuffer, srcFileName, dstFileNameEndPos); + /* The short tar extensions tzst, tgz, txz and tlz4 files should have "tar" extension on decompression + * To check that the file is one of them we can check that it starts with "t" + */ + if (suffixPtr[1] == 't') { + dstFileNameBuffer[dstFileNameEndPos++] = '.'; + dstFileNameBuffer[dstFileNameEndPos++] = 't'; + dstFileNameBuffer[dstFileNameEndPos++] = 'a'; + dstFileNameBuffer[dstFileNameEndPos++] = 'r'; + } dstFileNameBuffer[dstFileNameEndPos] = '\0'; return dstFileNameBuffer; From 91c3f545cc51fbcd8d5131ee06a944125911ac02 Mon Sep 17 00:00:00 2001 From: "W. Felix Handte" Date: Thu, 24 Oct 2019 20:18:57 -0400 Subject: [PATCH 09/11] Fix Build; Refactor --- programs/fileio.c | 122 ++++++++++++++++++++++++++++++---------------- programs/fileio.h | 15 ++++-- 2 files changed, 91 insertions(+), 46 deletions(-) diff --git a/programs/fileio.c b/programs/fileio.c index 07503f05..c2c5618e 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -1496,17 +1496,17 @@ FIO_determineCompressedName(const char* srcFileName, const char* outDirName, con static char* dstFileNameBuffer = NULL; /* using static allocation : this function cannot be multi-threaded */ char* outDirFilename = NULL; size_t sfnSize = strlen(srcFileName); - size_t const suffixSize = strlen(suffix); + size_t const srcSuffixLen = strlen(suffix); if (outDirName) { - outDirFilename = FIO_createFilename_fromOutDir(srcFileName, outDirName, suffixSize); + outDirFilename = FIO_createFilename_fromOutDir(srcFileName, outDirName, srcSuffixLen); sfnSize = strlen(outDirFilename); assert(outDirFilename != NULL); } - if (dfnbCapacity <= sfnSize+suffixSize+1) { + if (dfnbCapacity <= sfnSize+srcSuffixLen+1) { /* resize buffer for dstName */ free(dstFileNameBuffer); - dfnbCapacity = sfnSize + suffixSize + 30; + dfnbCapacity = sfnSize + srcSuffixLen + 30; dstFileNameBuffer = (char*)malloc(dfnbCapacity); if (!dstFileNameBuffer) { EXM_THROW(30, "zstd: %s", strerror(errno)); @@ -1520,7 +1520,7 @@ FIO_determineCompressedName(const char* srcFileName, const char* outDirName, con } else { memcpy(dstFileNameBuffer, srcFileName, sfnSize); } - memcpy(dstFileNameBuffer+sfnSize, suffix, suffixSize+1 /* Include terminating null */); + memcpy(dstFileNameBuffer+sfnSize, suffix, srcSuffixLen+1 /* Include terminating null */); return dstFileNameBuffer; } @@ -2287,6 +2287,37 @@ int FIO_decompressFilename(FIO_prefs_t* const prefs, return decodingError; } +static const char *suffixList[] = { + ZSTD_EXTENSION, + TZSTD_EXTENSION, +#ifdef ZSTD_GZDECOMPRESS + GZ_EXTENSION, + TGZ_EXTENSION, +#endif +#ifdef ZSTD_LZMADECOMPRESS + LZMA_EXTENSION, + XZ_EXTENSION, + TXZ_EXTENSION, +#endif +#ifdef ZSTD_LZ4DECOMPRESS + LZ4_EXTENSION, + TLZ4_EXTENSION, +#endif + NULL +}; + +static const char *suffixListStr = + ZSTD_EXTENSION "/" TZSTD_EXTENSION +#ifdef ZSTD_GZDECOMPRESS + "/" GZ_EXTENSION "/" TGZ_EXTENSION +#endif +#ifdef ZSTD_LZMADECOMPRESS + "/" LZMA_EXTENSION "/" XZ_EXTENSION "/" TXZ_EXTENSION +#endif +#ifdef ZSTD_LZ4DECOMPRESS + "/" LZ4_EXTENSION "/" TLZ4_EXTENSION +#endif +; /* FIO_determineDstName() : * create a destination filename from a srcFileName. @@ -2297,72 +2328,79 @@ FIO_determineDstName(const char* srcFileName, const char* outDirName) { static size_t dfnbCapacity = 0; static char* dstFileNameBuffer = NULL; /* using static allocation : this function cannot be multi-threaded */ + size_t dstFileNameEndPos; char* outDirFilename = NULL; - - const char* SUFFIX_LIST = ZSTD_EXTENSION "/" TZSTD_EXTENSION - #ifdef ZSTD_GZDECOMPRESS - "/" GZ_EXTENSION "/" TGZ_EXTENSION - #endif - #ifdef ZSTD_LZMADECOMPRESS - "/" XZ_EXTENSION "/" LZMA_EXTENSION "/" TXZ_EXTENSION - #endif - #ifdef ZSTD_LZ4DECOMPRESS - "/" LZ4_EXTENSION "/" TLZ4_EXTENSION - #endif - ; + const char* dstSuffix = ""; + size_t dstSuffixLen = 0; size_t sfnSize = strlen(srcFileName); - size_t suffixSize; - const char* const suffixPtr = strrchr(srcFileName, '.'); - if (suffixPtr == NULL) { - DISPLAYLEVEL(1, "zstd: %s: missing suffix (%s expected). Can't derive the output file name so specify it with -o dstFileName. -- ignored \n", - srcFileName, SUFFIX_LIST); + size_t srcSuffixLen; + const char* const srcSuffix = strrchr(srcFileName, '.'); + if (srcSuffix == NULL) { + DISPLAYLEVEL(1, + "zstd: %s: unknown suffix (%s expected). " + "Can't derive the output file name. " + "Specify it with -o dstFileName. Ignoring.\n", + srcFileName, suffixListStr); return NULL; } - suffixSize = strlen(suffixPtr); + srcSuffixLen = strlen(srcSuffix); - /* check suffix is authorized */ - if (sfnSize <= suffixSize - || (strstr(SUFFIX_LIST, suffixPtr) == NULL)) { - DISPLAYLEVEL(1, "zstd: %s: unknown suffix (%s expected). Can't derive the output file name so specify it with -o dstFileName. -- ignored \n", - srcFileName, SUFFIX_LIST); - return NULL; + { + const char** matchedSuffixPtr; + for (matchedSuffixPtr = suffixList; *matchedSuffixPtr != NULL; matchedSuffixPtr++) { + if (!strcmp(*matchedSuffixPtr, srcSuffix)) { + break; + } + } + + /* check suffix is authorized */ + if (sfnSize <= srcSuffixLen || *matchedSuffixPtr == NULL) { + DISPLAYLEVEL(1, + "zstd: %s: unknown suffix (%s expected). " + "Can't derive the output file name. " + "Specify it with -o dstFileName. Ignoring.\n", + srcFileName, suffixListStr); + return NULL; + } + + if ((*matchedSuffixPtr)[1] == 't') { + dstSuffix = ".tar"; + dstSuffixLen = strlen(dstSuffix); + } } + if (outDirName) { outDirFilename = FIO_createFilename_fromOutDir(srcFileName, outDirName, 0); sfnSize = strlen(outDirFilename); assert(outDirFilename != NULL); } - if (dfnbCapacity+suffixSize <= sfnSize+1) { + if (dfnbCapacity+srcSuffixLen <= sfnSize+1+dstSuffixLen) { /* allocate enough space to write dstFilename into it */ free(dstFileNameBuffer); dfnbCapacity = sfnSize + 20; dstFileNameBuffer = (char*)malloc(dfnbCapacity); if (dstFileNameBuffer==NULL) - EXM_THROW(74, "%s : not enough memory for dstFileName", strerror(errno)); + EXM_THROW(74, "%s : not enough memory for dstFileName", + strerror(errno)); } /* return dst name == src name truncated from suffix */ assert(dstFileNameBuffer != NULL); - size_t dstFileNameEndPos = sfnSize - suffixSize; + dstFileNameEndPos = sfnSize - srcSuffixLen; if (outDirFilename) { memcpy(dstFileNameBuffer, outDirFilename, dstFileNameEndPos); free(outDirFilename); } else { memcpy(dstFileNameBuffer, srcFileName, dstFileNameEndPos); } - /* The short tar extensions tzst, tgz, txz and tlz4 files should have "tar" extension on decompression - * To check that the file is one of them we can check that it starts with "t" - */ - if (suffixPtr[1] == 't') { - dstFileNameBuffer[dstFileNameEndPos++] = '.'; - dstFileNameBuffer[dstFileNameEndPos++] = 't'; - dstFileNameBuffer[dstFileNameEndPos++] = 'a'; - dstFileNameBuffer[dstFileNameEndPos++] = 'r'; - } - dstFileNameBuffer[dstFileNameEndPos] = '\0'; + + /* The short tar extensions tzst, tgz, txz and tlz4 files should have "tar" + * extension on decompression. Also writes terminating null. */ + strcpy(dstFileNameBuffer + dstFileNameEndPos, dstSuffix); + dstFileNameEndPos += dstSuffixLen; return dstFileNameBuffer; /* note : dstFileNameBuffer memory is not going to be free */ diff --git a/programs/fileio.h b/programs/fileio.h index 42e2274a..39eb544a 100644 --- a/programs/fileio.h +++ b/programs/fileio.h @@ -30,15 +30,22 @@ extern "C" { #else # define nulmark "/dev/null" #endif + +/* We test whether the extension we found starts with 't', and if so, we append + * ".tar" to the end of the output name. + */ #define LZMA_EXTENSION ".lzma" #define XZ_EXTENSION ".xz" -#define TXZ_EXTENSION ".txz" +#define TXZ_EXTENSION ".txz" + #define GZ_EXTENSION ".gz" -#define TGZ_EXTENSION ".tgz" +#define TGZ_EXTENSION ".tgz" + #define ZSTD_EXTENSION ".zst" -#define TZSTD_EXTENSION ".tzst" +#define TZSTD_EXTENSION ".tzst" + #define LZ4_EXTENSION ".lz4" -#define TLZ4_EXTENSION ".tlz4" +#define TLZ4_EXTENSION ".tlz4" /*-************************************* From 24499036ba88dbead8cca53a6075c9229ef959f9 Mon Sep 17 00:00:00 2001 From: "W. Felix Handte" Date: Thu, 24 Oct 2019 20:19:10 -0400 Subject: [PATCH 10/11] Add Tests --- tests/playTests.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/playTests.sh b/tests/playTests.sh index f68ee81a..9d9c8e3d 100755 --- a/tests/playTests.sh +++ b/tests/playTests.sh @@ -845,6 +845,46 @@ if [ $LZ4MODE -ne 1 ]; then grep ".lz4" tmplg > $INTOVOID && die "Unsupported suffix listed" fi +println "\n===> tar extension tests " + +rm -f tmp tmp.tar tmp.tzst tmp.tgz tmp.txz tmp.tlz4 + +./datagen > tmp +tar cf tmp.tar tmp +$ZSTD tmp.tar -o tmp.tzst +rm tmp.tar +$ZSTD -d tmp.tzst +[ -e tmp.tar ] || die ".tzst failed to decompress to .tar!" +rm -f tmp.tar tmp.tzst + +if [ $GZIPMODE -eq 1 ]; then + tar czf tmp.tgz tmp + $ZSTD -d tmp.tgz + [ -e tmp.tar ] || die ".tgz failed to decompress to .tar!" + rm -f tmp.tar tmp.tgz +fi + +if [ $LZMAMODE -eq 1 ]; then + tar c tmp | xz > tmp.txz + $ZSTD -d tmp.txz + [ -e tmp.tar ] || die ".txz failed to decompress to .tar!" + rm -f tmp.tar tmp.txz +fi + +if [ $LZ4MODE -eq 1 ]; then + tar c tmp | lz4 > tmp.tlz4 + $ZSTD -d tmp.tlz4 + [ -e tmp.tar ] || die ".tlz4 failed to decompress to .tar!" + rm -f tmp.tar tmp.tlz4 +fi + +touch tmp.t tmp.tz tmp.tzs +! $ZSTD -d tmp.t +! $ZSTD -d tmp.tz +! $ZSTD -d tmp.tzs + +exit + println "\n===> zstd round-trip tests " roundTripTest From 4eccc82875d6e5ca8a621fc80acd363a5efb9d3f Mon Sep 17 00:00:00 2001 From: "W. Felix Handte" Date: Fri, 25 Oct 2019 13:58:58 -0400 Subject: [PATCH 11/11] Minor Fixes --- programs/fileio.c | 1 - programs/fileio.h | 3 ++- tests/playTests.sh | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/programs/fileio.c b/programs/fileio.c index c2c5618e..828878c6 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -2400,7 +2400,6 @@ FIO_determineDstName(const char* srcFileName, const char* outDirName) /* The short tar extensions tzst, tgz, txz and tlz4 files should have "tar" * extension on decompression. Also writes terminating null. */ strcpy(dstFileNameBuffer + dstFileNameEndPos, dstSuffix); - dstFileNameEndPos += dstSuffixLen; return dstFileNameBuffer; /* note : dstFileNameBuffer memory is not going to be free */ diff --git a/programs/fileio.h b/programs/fileio.h index 39eb544a..af2c5d9d 100644 --- a/programs/fileio.h +++ b/programs/fileio.h @@ -31,7 +31,8 @@ extern "C" { # define nulmark "/dev/null" #endif -/* We test whether the extension we found starts with 't', and if so, we append +/** + * We test whether the extension we found starts with 't', and if so, we append * ".tar" to the end of the output name. */ #define LZMA_EXTENSION ".lzma" diff --git a/tests/playTests.sh b/tests/playTests.sh index 9d9c8e3d..c1da1650 100755 --- a/tests/playTests.sh +++ b/tests/playTests.sh @@ -865,14 +865,14 @@ if [ $GZIPMODE -eq 1 ]; then fi if [ $LZMAMODE -eq 1 ]; then - tar c tmp | xz > tmp.txz + tar c tmp | $ZSTD --format=xz > tmp.txz $ZSTD -d tmp.txz [ -e tmp.tar ] || die ".txz failed to decompress to .tar!" rm -f tmp.tar tmp.txz fi if [ $LZ4MODE -eq 1 ]; then - tar c tmp | lz4 > tmp.tlz4 + tar c tmp | $ZSTD --format=lz4 > tmp.tlz4 $ZSTD -d tmp.tlz4 [ -e tmp.tar ] || die ".tlz4 failed to decompress to .tar!" rm -f tmp.tar tmp.tlz4