From d0519d4b0cc88ae965bcfffb2efbee7f2eda425d Mon Sep 17 00:00:00 2001 From: "W. Felix Handte" Date: Thu, 28 Sep 2017 19:18:15 -0400 Subject: [PATCH] Add CLI Program Name Detection for LZ4 --- programs/zstdcli.c | 4 ++++ tests/Makefile | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/programs/zstdcli.c b/programs/zstdcli.c index 89e97c29..20a1b217 100644 --- a/programs/zstdcli.c +++ b/programs/zstdcli.c @@ -61,6 +61,8 @@ #define ZSTD_UNLZMA "unlzma" #define ZSTD_XZ "xz" #define ZSTD_UNXZ "unxz" +#define ZSTD_LZ4 "lz4" +#define ZSTD_UNLZ4 "unlz4" #define KB *(1 <<10) #define MB *(1 <<20) @@ -425,6 +427,8 @@ int main(int argCount, const char* argv[]) if (exeNameMatch(programName, ZSTD_UNLZMA)) { operation=zom_decompress; FIO_setCompressionType(FIO_lzmaCompression); FIO_setRemoveSrcFile(1); } /* behave like unlzma */ if (exeNameMatch(programName, ZSTD_XZ)) { suffix = XZ_EXTENSION; FIO_setCompressionType(FIO_xzCompression); FIO_setRemoveSrcFile(1); } /* behave like xz */ if (exeNameMatch(programName, ZSTD_UNXZ)) { operation=zom_decompress; FIO_setCompressionType(FIO_xzCompression); FIO_setRemoveSrcFile(1); } /* behave like unxz */ + if (exeNameMatch(programName, ZSTD_LZ4)) { suffix = LZ4_EXTENSION; FIO_setCompressionType(FIO_lz4Compression); FIO_setRemoveSrcFile(1); } /* behave like xz */ + if (exeNameMatch(programName, ZSTD_UNLZ4)) { operation=zom_decompress; FIO_setCompressionType(FIO_lz4Compression); FIO_setRemoveSrcFile(1); } /* behave like unxz */ memset(&compressionParams, 0, sizeof(compressionParams)); /* command switches */ diff --git a/tests/Makefile b/tests/Makefile index f30398c0..0741170c 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -375,16 +375,27 @@ test-pool: poolTests $(QEMU_SYS) ./poolTests test-lz4: ZSTD = LD_LIBRARY_PATH=/usr/local/lib $(PRGDIR)/zstd +test-lz4: ZSTD_LZ4 = LD_LIBRARY_PATH=/usr/local/lib ./lz4 +test-lz4: ZSTD_UNLZ4 = LD_LIBRARY_PATH=/usr/local/lib ./unlz4 test-lz4: zstd decodecorpus + ln -s $(PRGDIR)/zstd lz4 + ln -s $(PRGDIR)/zstd unlz4 + ./decodecorpus -ptmp # lz4 -> zstd lz4 < tmp | \ $(ZSTD) -d | \ cmp - tmp + lz4 < tmp | \ + $(ZSTD_UNLZ4) | \ + cmp - tmp # zstd -> lz4 $(ZSTD) --format=lz4 < tmp | \ lz4 -d | \ cmp - tmp + $(ZSTD_LZ4) < tmp | \ + lz4 -d | \ + cmp - tmp # zstd -> zstd $(ZSTD) --format=lz4 < tmp | \ $(ZSTD) -d | \ @@ -394,6 +405,6 @@ test-lz4: zstd decodecorpus $(ZSTD) -d | \ cmp - tmp - rm tmp + rm tmp lz4 unlz4 endif