diff --git a/main.c b/main.c index 3594b47..4d1f24a 100644 --- a/main.c +++ b/main.c @@ -764,48 +764,49 @@ static void display(struct uns_ctr *ctr) tmp.p = gc.record_get_ptr(ctr->p, 1); display(&tmp); - tmp.p = gc.record_get_ptr(ctr->p, 2); - switch (get_type(tmp.p)) { + ctr->p = gc.record_get_ptr(ctr->p, 2); + while (get_type(ctr->p) == CELL) { + printf(" "); + tmp.p = gc.record_get_ptr(ctr->p, 1); + display(&tmp); + ctr->p = gc.record_get_ptr(ctr->p, 2); + } + + switch (get_type(ctr->p)) { case EMPTY_LIST: - printf(")"); - goto remove; - case CELL: - printf(" "); - display(&tmp); printf(")"); break; - default: + default: printf(" . "); - display(&tmp); + display(ctr); printf(")"); break; } - remove: uns_root_remove(&gc, &tmp); return; case INTEGER: memcpy(&l, gc.record_get_ptr(ctr->p, 1), sizeof(long)); - printf("%ld ", l); + printf("%ld", l); return; case FLOAT: memcpy(&f, gc.record_get_ptr(ctr->p, 1), sizeof(double)); - printf("%f ", f); + printf("%f", f); return; case STRING: tmp.p = gc.record_get_ptr(ctr->p, 1); uns_root_add(&gc, &tmp); - printf("\"%s\" ", uns_string_cstring(&gc, &tmp)); + printf("\"%s\"", uns_string_cstring(&gc, &tmp)); uns_root_remove(&gc, &tmp); return; case SYMBOL: tmp.p = gc.record_get_ptr(ctr->p, 1); uns_root_add(&gc, &tmp); - printf("%s ", uns_string_cstring(&gc, &tmp)); + printf("%s", uns_string_cstring(&gc, &tmp)); uns_root_remove(&gc, &tmp); return; case EMPTY_LIST: - printf("'() "); + printf("'()"); return; default: abort();