From 687cf8fdb5154a4f965b48b04e740cd79b2eb950 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Sun, 31 Mar 2013 00:20:54 -0400 Subject: [PATCH] fix bug printing custom cvalue types that lack print methods --- cvalues.c | 1 - print.c | 16 +++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cvalues.c b/cvalues.c index 37a7c20..ad18d1c 100644 --- a/cvalues.c +++ b/cvalues.c @@ -768,7 +768,6 @@ static numerictype_t sym_to_numtype(value_t type) return T_FLOAT; else if (type == doublesym) return T_DOUBLE; - assert(0); return N_NUMTYPES; } diff --git a/print.c b/print.c index 586d0bd..4f673a0 100644 --- a/print.c +++ b/print.c @@ -700,11 +700,17 @@ static void cvalue_printdata(ios_t *f, void *data, size_t len, value_t type, else if (issymbol(type)) { // handle other integer prims. we know it's smaller than uint64 // at this point, so int64 is big enough to capture everything. - int64_t i64 = conv_to_int64(data, sym_to_numtype(type)); - if (weak || print_princ) - HPOS += ios_printf(f, "%lld", i64); - else - HPOS += ios_printf(f, "#%s(%lld)", symbol_name(type), i64); + numerictype_t nt = sym_to_numtype(type); + if (nt == N_NUMTYPES) { + HPOS += ios_printf(f, "#<%s>", symbol_name(type)); + } + else { + int64_t i64 = conv_to_int64(data, sym_to_numtype(type)); + if (weak || print_princ) + HPOS += ios_printf(f, "%lld", i64); + else + HPOS += ios_printf(f, "#%s(%lld)", symbol_name(type), i64); + } } else if (iscons(type)) { if (car_(type) == arraysym) {