]> granicus.if.org Git - jq/commitdiff
src/main.c: fix issue #1587 by using jv_dumpf in the raw-output and ascii-output...
authorrain1 <rain1@airmail.cc>
Thu, 1 Mar 2018 19:16:11 +0000 (19:16 +0000)
committerNico Williams <nico@cryptonector.com>
Thu, 1 Mar 2018 20:33:47 +0000 (14:33 -0600)
src/main.c

index be436dd8c53d71fd1331d08adc117e1d6030bb09..b154689efd5c5f41bf9f8ec46b95242e9799733e 100644 (file)
@@ -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 {