aboutsummaryrefslogtreecommitdiff
path: root/c/tools
diff options
context:
space:
mode:
authorEugene Kliuchnikov <eustas@google.com>2017-09-19 15:57:15 +0200
committerGitHub <noreply@github.com>2017-09-19 15:57:15 +0200
commit37fb83ec0dd1c52b6b464bf17515db1aeed846b3 (patch)
treec7977487df11cbe79a5dda1f611ca071ff4e47d7 /c/tools
parent61a501593806938abc1849f174447c2c41ad4418 (diff)
downloadbrotli-37fb83ec0dd1c52b6b464bf17515db1aeed846b3.zip
brotli-37fb83ec0dd1c52b6b464bf17515db1aeed846b3.tar.gz
brotli-37fb83ec0dd1c52b6b464bf17515db1aeed846b3.tar.bz2
Update: (#600)
* encoder: relax backward references candidates asserts * encoder: make RNG more platform-independent * encoder: remove "unused" param (context mode) * CLI: improve first-encounter experience * Java: update SynthTest * Java: refine proguard config * Java/JNI: fix one-shot compression workflow
Diffstat (limited to 'c/tools')
-rwxr-xr-xc/tools/brotli.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/c/tools/brotli.c b/c/tools/brotli.c
index 616ab50..f23917a 100755
--- a/c/tools/brotli.c
+++ b/c/tools/brotli.c
@@ -15,6 +15,7 @@
#include <sys/types.h>
#include <time.h>
+#include "../common/constants.h"
#include "../common/version.h"
#include <brotli/decode.h>
#include <brotli/encode.h>
@@ -38,6 +39,7 @@
#endif
#define fdopen _fdopen
+#define isatty _isatty
#define unlink _unlink
#define utimbuf _utimbuf
#define utime _utime
@@ -685,6 +687,11 @@ static BROTLI_BOOL DecompressFiles(Context* context) {
return BROTLI_FALSE;
}
is_ok = OpenFiles(context);
+ if (is_ok && !context->current_input_path &&
+ !context->force_overwrite && isatty(STDIN_FILENO)) {
+ fprintf(stderr, "Use -h help. Use -f to force input from a terminal.\n");
+ is_ok = BROTLI_FALSE;
+ }
if (is_ok) is_ok = DecompressFile(context, s);
BrotliDecoderDestroyInstance(s);
if (!CloseFiles(context, is_ok)) is_ok = BROTLI_FALSE;
@@ -750,6 +757,11 @@ static BROTLI_BOOL CompressFiles(Context* context) {
BrotliEncoderSetParameter(s,
BROTLI_PARAM_LGWIN, (uint32_t)context->lgwin);
is_ok = OpenFiles(context);
+ if (is_ok && !context->current_output_path &&
+ !context->force_overwrite && isatty(STDOUT_FILENO)) {
+ fprintf(stderr, "Use -h help. Use -f to force output to a terminal.\n");
+ is_ok = BROTLI_FALSE;
+ }
if (is_ok) is_ok = CompressFile(context, s);
BrotliEncoderDestroyInstance(s);
if (!CloseFiles(context, is_ok)) is_ok = BROTLI_FALSE;