]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
When reading from stdin, write to stdout by default
authorNick Terrell <terrelln@fb.com>
Fri, 2 Sep 2016 19:35:36 +0000 (12:35 -0700)
committerNick Terrell <terrelln@fb.com>
Fri, 2 Sep 2016 19:35:36 +0000 (12:35 -0700)
contrib/pzstd/Options.cpp

index 693e9a515f5ca233df8c9329a8e7b47925abd2f2..61613099691db551a9e1112dabc1e71e56c7b769 100644 (file)
@@ -146,23 +146,21 @@ bool Options::parse(int argc, const char** argv) {
   // Determine output file if not specified
   if (outputFile.empty()) {
     if (inputFile == "-") {
-      std::fprintf(
-          stderr,
-          "Invalid arguments: Reading from stdin, but -o not provided.\n");
-      return false;
-    }
-    // Attempt to add/remove zstd extension from the input file
-    if (decompress) {
-      int stemSize = inputFile.size() - zstdExtension.size();
-      if (stemSize > 0 && inputFile.substr(stemSize) == zstdExtension) {
-        outputFile = inputFile.substr(0, stemSize);
+      outputFile = "-";
+    } else {
+      // Attempt to add/remove zstd extension from the input file
+      if (decompress) {
+        int stemSize = inputFile.size() - zstdExtension.size();
+        if (stemSize > 0 && inputFile.substr(stemSize) == zstdExtension) {
+          outputFile = inputFile.substr(0, stemSize);
+        } else {
+          std::fprintf(
+              stderr, "Invalid argument: Unable to determine output file.\n");
+          return false;
+        }
       } else {
-        std::fprintf(
-            stderr, "Invalid argument: Unable to determine output file.\n");
-        return false;
+        outputFile = inputFile + zstdExtension;
       }
-    } else {
-      outputFile = inputFile + zstdExtension;
     }
   }
   // Check compression level