Skip to content
Myr

jv_show() should be able to display invalid values

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Nicolas Williams · committed by Nicolas Williams · parent 539dcca · Browse files · 2 files+15 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+15 added−3 removed

  • other:+15 added−3 removed

2 files+15 added−3 removed

modified:jv_print.c+14 added-2 removed
125 unmodified lines
126 }127 switch (jv_get_kind(x)) {128 default:129 case JV_KIND_INVALID:130 if (flags & JV_PRINT_INVALID) {131 jv msg = jv_invalid_get_msg(jv_copy(x));132 if (jv_get_kind(msg) == JV_KIND_STRING) {133 put_str("<invalid:", F, S);134 jvp_dump_string(msg, flags | JV_PRINT_ASCII, F, S);135 put_str(">", F, S);136 } else {137 put_str("<invalid>", F, S);138 }139 } else {130 assert(0 && "Invalid value");140 assert(0 && "Invalid value");141 }142 break;143 case JV_KIND_NULL:144 put_str("null", F, S);145 break;
135 unmodified lines
281void jv_dump(jv x, int flags) {282 jv_dumpf(x, stdout, flags);283}284285/* This one is nice for use in debuggers */286void jv_show(jv x, int flags) {287 if (flags == -1)288 flags = JV_PRINT_PRETTY | JV_PRINT_COLOUR;277 jv_dumpf(jv_copy(x), stderr, flags);289 jv_dumpf(jv_copy(x), stderr, flags | JV_PRINT_INVALID);290 fflush(stderr);291}292293jv jv_dump_string(jv x, int flags) {
7 unmodified lines
modified:jv.h+1 added-1 removed
124 unmodified lines
125126127int jv_get_refcnt(jv);128129enum { JV_PRINT_PRETTY = 1, JV_PRINT_ASCII = 2, JV_PRINT_COLOUR = 4, JV_PRINT_SORTED = 8 };129enum { JV_PRINT_PRETTY = 1, JV_PRINT_ASCII = 2, JV_PRINT_COLOUR = 4, JV_PRINT_SORTED = 8, JV_PRINT_INVALID = 16 };130void jv_dumpf(jv, FILE *f, int flags);131void jv_dump(jv, int flags);132void jv_show(jv, int flags);133jv jv_dump_string(jv, int flags);
50 unmodified lines