Skip to content

Commit

Permalink
Merge pull request #252 from jow-/main-pretty-print-by-default
Browse files Browse the repository at this point in the history
main: pretty-print `-p` output by default
  • Loading branch information
jow- authored Dec 6, 2024
2 parents 9150505 + 0a7ff47 commit 725f637
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 725f637

Please sign in to comment.