From 573fa33d1d2793da996eb6edad820c67439ce6a0 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Fri, 28 Jan 2022 17:08:44 -0800 Subject: added test for --list from stdin --- programs/lz4cli.c | 5 ++++- programs/lz4io.c | 2 +- tests/Makefile | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/programs/lz4cli.c b/programs/lz4cli.c index 49fa492..b5cb000 100644 --- a/programs/lz4cli.c +++ b/programs/lz4cli.c @@ -724,7 +724,10 @@ int main(int argc, const char** argv) if (!output_filename) output_filename = "*\\dummy^!//"; /* Check if output is defined as console; trigger an error in this case */ - if (!strcmp(output_filename,stdoutmark) && mode != om_list && IS_CONSOLE(stdout) && !forceStdout) { + if ( !strcmp(output_filename,stdoutmark) + && mode != om_list + && IS_CONSOLE(stdout) + && !forceStdout) { DISPLAYLEVEL(1, "refusing to write to console without -c \n"); exit(1); } diff --git a/programs/lz4io.c b/programs/lz4io.c index 4cdd3cc..a4c21ee 100644 --- a/programs/lz4io.c +++ b/programs/lz4io.c @@ -1639,7 +1639,7 @@ int LZ4IO_displayCompressedFilesInfo(const char** inFileNames, size_t ifnIdx) /* Get file info */ LZ4IO_cFileInfo_t cfinfo = LZ4IO_INIT_CFILEINFO; cfinfo.fileName = LZ4IO_baseName(inFileNames[idx]); - if (strcmp(inFileNames[idx], stdinmark) == 0 ? !UTIL_isRegFD(0) : !UTIL_isRegFile(inFileNames[idx])) { + if ((strcmp(inFileNames[idx], stdinmark) == 0) ? !UTIL_isRegFD(0) : !UTIL_isRegFile(inFileNames[idx])) { DISPLAYLEVEL(1, "lz4: %s is not a regular file \n", inFileNames[idx]); return 0; } diff --git a/tests/Makefile b/tests/Makefile index 00f6f3b..d75fabe 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -360,6 +360,7 @@ test-lz4-basic: lz4 datagen unlz4 lz4cat $(DIFF) -q tmp-tlb-hw tmp-tlb4 $(LZ4) -f tmp-tlb-hw $(LZ4) --list tmp-tlb-hw.lz4 # test --list on valid single-frame file + $(LZ4) --list < tmp-tlb-hw.lz4 # test --list from stdin (file only) $(CAT) tmp-tlb-hw >> tmp-tlb-hw.lz4 $(LZ4) -f tmp-tlb-hw.lz4 # uncompress valid frame followed by invalid data $(LZ4) -BX tmp-tlb-hw -c -q | $(LZ4) -tv # test block checksum -- cgit v0.12