diff options
| author | 2024-06-23 00:44:54 -0400 | |
|---|---|---|
| committer | 2024-06-23 00:44:54 -0400 | |
| commit | 38b044921f8b788a07af25e01ab704316f519a86 (patch) | |
| tree | 21598031ad1cdf417e7e4f4bc440ccac89616a65 | |
| parent | quality of life printing improvements (diff) | |
prettier printing
| -rw-r--r-- | main.c | 29 |
1 files changed, 15 insertions, 14 deletions
@@ -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)) { - case EMPTY_LIST: - printf(")"); - goto remove; - case CELL: + 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(")"); 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(); |
