summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoritchyny <itchyny@cybozu.co.jp>2023-06-28 17:54:40 +0900
committerGitHub <noreply@github.com>2023-06-28 17:54:40 +0900
commit82d56022309ad6bddb191d51b219f19604a96171 (patch)
tree2bba8af6109bc297780201ceabbf76c5af57e2ca
parent7c1efd67ff6c835547c84a1f153403fdda4abe97 (diff)
Fix "writing output failed" error of non ASCII output on Windows (#2633)
-rw-r--r--src/main.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index 1cc65425..9b63dca8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -183,7 +183,8 @@ static int process(jq_state *jq, jv value, int flags, int dumpopts) {
if (options & ASCII_OUTPUT) {
jv_dumpf(jv_copy(result), stdout, JV_PRINT_ASCII);
} else {
- fwrite(jv_string_value(result), 1, jv_string_length_bytes(jv_copy(result)), stdout);
+ priv_fwrite(jv_string_value(result), jv_string_length_bytes(jv_copy(result)),
+ stdout, dumpopts & JV_PRINT_ISATTY);
}
ret = JQ_OK;
jv_free(result);
@@ -217,8 +218,8 @@ static int process(jq_state *jq, jv value, int flags, int dumpopts) {
jv error_message = jq_get_error_message(jq);
if (jv_get_kind(error_message) == JV_KIND_STRING) {
// No prefix should be added to the output of `halt_error`.
- fwrite(jv_string_value(error_message), 1,
- jv_string_length_bytes(jv_copy(error_message)), stderr);
+ priv_fwrite(jv_string_value(error_message), jv_string_length_bytes(jv_copy(error_message)),
+ stderr, dumpopts & JV_PRINT_ISATTY);
} else if (jv_get_kind(error_message) == JV_KIND_NULL) {
// Halt with no output
} else if (jv_is_valid(error_message)) {