summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrain1 <rain1@airmail.cc>2018-03-01 19:16:11 +0000
committerNico Williams <nico@cryptonector.com>2018-03-01 14:33:47 -0600
commitbf88c73c20ff1642aa2566ae67df18ca5b4b63ab (patch)
tree06ce97e4a98db06c5c167a918ef6f18c3f9d6870
parentae11f111a5d18604c7001e48c3d6e4a5e73fed64 (diff)
src/main.c: fix issue #1587 by using jv_dumpf in the raw-output and ascii-output case. retain fwrite in the raw-output case.
-rw-r--r--src/main.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index be436dd8..b154689e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -167,7 +167,11 @@ static int process(jq_state *jq, jv value, int flags, int dumpopts) {
jv result;
while (jv_is_valid(result = jq_next(jq))) {
if ((options & RAW_OUTPUT) && jv_get_kind(result) == JV_KIND_STRING) {
- fwrite(jv_string_value(result), 1, jv_string_length_bytes(jv_copy(result)), stdout);
+ if (options & ASCII_OUTPUT) {
+ jv_dumpf(result, stdout, JV_PRINT_ASCII);
+ } else {
+ fwrite(jv_string_value(result), 1, jv_string_length_bytes(jv_copy(result)), stdout);
+ }
ret = 0;
jv_free(result);
} else {