diff --git a/c/print.h b/c/print.h index 656d358..8ecc498 100644 --- a/c/print.h +++ b/c/print.h @@ -1,7 +1,7 @@ extern void *memrchr(const void *s, int c, size_t n); -// not *print-readably* -- use `display` repr instead of `write` repr -static int print_princ; +// *print-readably* -- use `write` repr instead of `display` repr +static int print_readably; // *print-pretty* -- indent instead of printing everything on one long line static int print_pretty; @@ -404,7 +404,7 @@ void fl_print_child(struct ios *f, value_t v) break; case TAG_SYM: name = symbol_name(v); - if (print_princ) + if (!print_readably) outs(name, f); else if (ismanaged(v)) { outsn("#:", f, 2); @@ -422,12 +422,12 @@ void fl_print_child(struct ios *f, value_t v) } else if (v == FL_EOF) { outsn("#", f, 6); } else if (isbuiltin(v)) { - if (!print_princ) + if (print_readably) outsn("#.", f, 2); outs(builtin_names[uintval(v)], f); } else { assert(isclosure(v)); - if (!print_princ) { + if (print_readably) { struct function *fn; char *data; size_t i, sz; @@ -468,7 +468,7 @@ void fl_print_child(struct ios *f, value_t v) case TAG_CVALUE: case TAG_VECTOR: case TAG_CONS: - if (!print_princ && print_circle_prefix(f, v)) + if (print_readably && print_circle_prefix(f, v)) break; if (isvector(v)) { int newindent, est, sz, i; @@ -639,7 +639,7 @@ static void cvalue_printdata(struct ios *f, void *data, size_t len, { if (type == bytesym) { unsigned char ch = *(unsigned char *)data; - if (print_princ) + if (!print_readably) outc(ch, f); else if (weak) HPOS += ios_printf(f, "#x%hhx", ch); @@ -651,7 +651,7 @@ static void cvalue_printdata(struct ios *f, void *data, size_t len, size_t nb = u8_toutf8(seq, sizeof(seq), &wc, 1); seq[nb] = '\0'; - if (print_princ) { + if (!print_readably) { // TODO: better multibyte handling if (wc == 0) ios_putc(0, f); @@ -705,7 +705,7 @@ static void cvalue_printdata(struct ios *f, void *data, size_t len, rep = sign_bit(d) ? "-nan.0" : "+nan.0"; else rep = sign_bit(d) ? "-inf.0" : "+inf.0"; - if (type == floatsym && !print_princ && !weak) + if (type == floatsym && print_readably && !weak) HPOS += ios_printf(f, "#%s(%s)", symbol_name(type), rep); else outs(rep, f); @@ -714,7 +714,7 @@ static void cvalue_printdata(struct ios *f, void *data, size_t len, outsn("-0.0", f, 4); else outsn("0.0", f, 3); - if (type == floatsym && !print_princ && !weak) + if (type == floatsym && print_readably && !weak) outc('f', f); } else { int hasdec; @@ -724,7 +724,7 @@ static void cvalue_printdata(struct ios *f, void *data, size_t len, outs(buf, f); if (!hasdec) outsn(".0", f, 2); - if (type == floatsym && !print_princ && !weak) + if (type == floatsym && print_readably && !weak) outc('f', f); } } else if (type == uint64sym @@ -733,7 +733,7 @@ static void cvalue_printdata(struct ios *f, void *data, size_t len, #endif ) { uint64_t ui64 = *(uint64_t *)data; - if (weak || print_princ) + if (weak || !print_readably) HPOS += ios_printf(f, "%llu", ui64); else HPOS += ios_printf(f, "#%s(%llu)", symbol_name(type), ui64); @@ -745,7 +745,7 @@ static void cvalue_printdata(struct ios *f, void *data, size_t len, HPOS += ios_printf(f, "#<%s>", symbol_name(type)); } else { int64_t i64 = conv_to_int64(data, nt); - if (weak || print_princ) + if (weak || !print_readably) HPOS += ios_printf(f, "%lld", i64); else HPOS += ios_printf(f, "#%s(%lld)", symbol_name(type), i64); @@ -765,7 +765,7 @@ static void cvalue_printdata(struct ios *f, void *data, size_t len, cnt = elsize ? len / elsize : 0; } if (eltype == bytesym) { - if (print_princ) { + if (!print_readably) { ios_write(f, data, len); /* char *nl = memrchr(data, '\n', len); @@ -837,7 +837,7 @@ static void cvalue_print(struct ios *f, value_t v) HPOS += ios_printf(f, "#", (size_t)(builtin_t)fptr); } else { - if (print_princ) { + if (!print_readably) { outs(symbol_name(label), f); } else { outsn("#fn(", f, 4); @@ -872,7 +872,7 @@ void fl_print(struct ios *f, value_t v) print_pretty = (symbol_value(printprettysym) != FL_F); if (print_pretty) set_print_width(); - print_princ = (symbol_value(printreadablysym) == FL_F); + print_readably = (symbol_value(printreadablysym) != FL_F); pl = symbol_value(printlengthsym); if (isfixnum(pl)) @@ -887,7 +887,7 @@ void fl_print(struct ios *f, value_t v) P_LEVEL = 0; printlabel = 0; - if (!print_princ) + if (print_readably) print_traverse(v); HPOS = VPOS = 0;