summaryrefslogtreecommitdiffstats
path: root/programs/lz4cli.c
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2016-12-08 22:17:40 (GMT)
committerYann Collet <cyan@fb.com>2016-12-08 22:25:04 (GMT)
commitde93e9e5d84fef6c5741ff0d72306fdb2baade1e (patch)
treec8ab766f88d9ae22553695b6b0060fbbc83a4aeb /programs/lz4cli.c
parent0280cf40dd01caa784d291480aaead9987ae9f9a (diff)
downloadlz4-de93e9e5d84fef6c5741ff0d72306fdb2baade1e.zip
lz4-de93e9e5d84fef6c5741ff0d72306fdb2baade1e.tar.gz
lz4-de93e9e5d84fef6c5741ff0d72306fdb2baade1e.tar.bz2
fix #285 : lz4cat doesn't work with stdin (reported by @beiDei8z)
Diffstat (limited to 'programs/lz4cli.c')
-rw-r--r--programs/lz4cli.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/programs/lz4cli.c b/programs/lz4cli.c
index b63d69d..5bd06d9 100644
--- a/programs/lz4cli.c
+++ b/programs/lz4cli.c
@@ -313,6 +313,7 @@ int main(int argc, const char** argv)
DISPLAY("Allocation error : not enough memory \n");
return 1;
}
+ inFileNames[0] = stdinmark;
LZ4IO_setOverwrite(0);
/* lz4cat predefined behavior */
@@ -468,7 +469,7 @@ int main(int argc, const char** argv)
break;
#ifdef UTIL_HAS_CREATEFILELIST
- /* recursive */
+ /* recursive */
case 'r': recursive=1; /* without break */
#endif
/* Treat non-option args as input files. See https://code.google.com/p/lz4/issues/detail?id=151 */
@@ -482,7 +483,7 @@ int main(int argc, const char** argv)
iters = readU32FromChar(&argument);
argument--;
BMK_setNotificationLevel(displayLevel);
- BMK_SetNbSeconds(iters);
+ BMK_SetNbSeconds(iters); /* notification if displayLevel >= 3 */
}
break;
@@ -555,6 +556,9 @@ int main(int argc, const char** argv)
DISPLAYLEVEL(1, "refusing to read from a console\n");
exit(1);
}
+ /* if input==stdin and no output defined, stdout becomes default output */
+ if (!strcmp(input_filename, stdinmark) && !output_filename)
+ output_filename = stdoutmark;
/* No output filename ==> try to select one automatically (when possible) */
while ((!output_filename) && (multiple_inputs==0)) {
@@ -592,20 +596,19 @@ int main(int argc, const char** argv)
break;
}
- if (!output_filename) output_filename = "*\\dummy^!//";
-
/* Check if output is defined as console; trigger an error in this case */
+ if (!output_filename) output_filename = "*\\dummy^!//";
if (!strcmp(output_filename,stdoutmark) && IS_CONSOLE(stdout) && !forceStdout) {
DISPLAYLEVEL(1, "refusing to write to console without -c\n");
exit(1);
}
-
/* Downgrade notification level in stdout and multiple file mode */
if (!strcmp(output_filename,stdoutmark) && (displayLevel==2)) displayLevel=1;
if ((multiple_inputs) && (displayLevel==2)) displayLevel=1;
/* IO Stream/File */
LZ4IO_setNotificationLevel(displayLevel);
+ if (ifnIdx == 0) multiple_inputs = 0;
if (mode == om_decompress) {
if (multiple_inputs)
operationResult = LZ4IO_decompressMultipleFilenames(inFileNames, ifnIdx, !strcmp(output_filename,stdoutmark) ? stdoutmark : LZ4_EXTENSION);