From 46f74d79b7b2ae17825a15168034126e70dcc6a0 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Wed, 9 Nov 2016 16:57:33 -0800 Subject: fixed sparse on stdout --- programs/lz4.1 | 2 +- programs/lz4cli.c | 26 +++++++++++++++++++------- programs/lz4io.c | 1 + 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/programs/lz4.1 b/programs/lz4.1 index 5a28a83..fcc7980 100644 --- a/programs/lz4.1 +++ b/programs/lz4.1 @@ -22,7 +22,7 @@ is equivalent to .br .B lz4cat is equivalent to -.BR "lz4 \-dcf" +.BR "lz4 \-dcfm" .br .PP When writing scripts that need to decompress files, diff --git a/programs/lz4cli.c b/programs/lz4cli.c index 093b325..b8e34fa 100644 --- a/programs/lz4cli.c +++ b/programs/lz4cli.c @@ -302,7 +302,16 @@ int main(int argc, const char** argv) LZ4IO_setOverwrite(0); /* lz4cat predefined behavior */ - if (!strcmp(exeName, LZ4CAT)) { mode = om_decompress; LZ4IO_setOverwrite(1); forceStdout=1; output_filename=stdoutmark; displayLevel=1; } + if (!strcmp(exeName, LZ4CAT)) { + mode = om_decompress; + LZ4IO_setOverwrite(1); + forceStdout=1; + output_filename=stdoutmark; + displayLevel=1; + multiple_inputs=1; + inFileNames = (const char**) calloc(argc, sizeof(char*)); + if (inFileNames==NULL) { perror(exeName); exit(1); } + } if (!strcmp(exeName, UNLZ4)) { mode = om_decompress; } /* command switches */ @@ -429,8 +438,10 @@ int main(int argc, const char** argv) /* Benchmark */ case 'b': mode = om_bench; multiple_inputs=1; - if (inFileNames == NULL) + if (inFileNames == NULL) { inFileNames = (const char**) calloc(argc, sizeof(char*)); + if (inFileNames==NULL) { perror(exeName); exit(1); } + } break; #ifdef UTIL_HAS_CREATEFILELIST @@ -439,8 +450,10 @@ int main(int argc, const char** argv) #endif /* Treat non-option args as input files. See https://code.google.com/p/lz4/issues/detail?id=151 */ case 'm': multiple_inputs=1; - if (inFileNames == NULL) - inFileNames = (const char**) calloc(argc, sizeof(char*)); + if (inFileNames == NULL) { + inFileNames = (const char**) calloc(argc, sizeof(char*)); + if (inFileNames==NULL) { perror(exeName); exit(1); } + } break; /* Modify Nb Seconds (benchmark only) */ @@ -490,7 +503,6 @@ int main(int argc, const char** argv) /* No input filename ==> use stdin */ if (multiple_inputs) { input_filename = inFileNames[0]; - //output_filename = (const char*)(inFileNames[0]); #ifdef UTIL_HAS_CREATEFILELIST if (recursive) { /* at this stage, filenameTable is a list of paths, which can contain both files and directories */ extendedFileList = UTIL_createFileList(inFileNames, ifnIdx, &fileNamesBuf, &fileNamesNb); @@ -514,12 +526,12 @@ int main(int argc, const char** argv) if (mode == om_test) { LZ4IO_setTestMode(1); - output_filename=nulmark; + output_filename = nulmark; mode = om_decompress; /* defer to decompress */ } /* compress or decompress */ - if (!input_filename) { input_filename=stdinmark; } + if (!input_filename) input_filename = stdinmark; /* Check if input is defined as console; trigger an error in this case */ if (!strcmp(input_filename, stdinmark) && IS_CONSOLE(stdin) ) { DISPLAYLEVEL(1, "refusing to read from a console\n"); diff --git a/programs/lz4io.c b/programs/lz4io.c index e8c655c..110b530 100644 --- a/programs/lz4io.c +++ b/programs/lz4io.c @@ -1007,6 +1007,7 @@ int LZ4IO_decompressMultipleFilenames(const char** inFileNamesTable, int ifntSiz if (outFileName==NULL) exit(1); /* not enough memory */ ress.dstFile = stdout; SET_BINARY_MODE(stdout); + if (g_sparseFileSupport==1) g_sparseFileSupport = 0; for (i=0; i