diff options
author | Jo-Philipp Wich <jo@mein.io> | 2024-12-06 10:33:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-06 10:33:58 +0100 |
commit | 725f63726b897a7dbf83dc6f29a52e7fdcc75878 (patch) | |
tree | bac2a6c555169a65f4805f0f6b53502d9e0619ce | |
parent | 9150505f46bc9cbe33e31ad4475aedbf0584a431 (diff) | |
parent | 0a7ff4715cb8ec863ed061443aa77f986c840507 (diff) |
Merge pull request #252 from jow-/main-pretty-print-by-default
main: pretty-print `-p` output by default
-rw-r--r-- | main.c | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -145,11 +145,18 @@ compile(uc_vm_t *vm, uc_source_t *src, FILE *precompile, bool strip, char *inter switch (rc) { case STATUS_OK: if (print_result) { - uc_vm_stack_push(vm, res); - uc_vm_stack_push(vm, ucv_string_new("\n")); - uc_stdlib_function("print")(vm, 2); - uc_vm_stack_pop(vm); - uc_vm_stack_pop(vm); + if (ucv_type(res) == UC_STRING) { + fwrite(ucv_string_get(res), ucv_string_length(res), 1, stdout); + } + else { + uc_stringbuf_t *pb = xprintbuf_new(); + + ucv_to_stringbuf_formatted(vm, pb, res, 0, '\t', 1); + fwrite(pb->buf, pb->bpos, 1, stdout); + printbuf_free(pb); + } + + ucv_put(res); } rc = 0; |