diff options
Diffstat (limited to 'src/cklist.c')
-rw-r--r-- | src/cklist.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/src/cklist.c b/src/cklist.c index 32352df..b2a7803 100644 --- a/src/cklist.c +++ b/src/cklist.c @@ -127,25 +127,36 @@ cklist* list_copy_part(cklist *ckl, int from, int until) { } void list_print_lisp(cklist *ckl) { - list_rewind(ckl); - printf("( \"%s\"", list_get(ckl)); - while (list_next(ckl)) { - if (ckl->pos == ckl->size-1) { - printf(", \"%s\" )\n", list_get(ckl)); + if (ckl->size > 0) { + list_rewind(ckl); + printf("( \"%s\"", list_get(ckl)); + if (ckl->size == 1) { + printf(" )\n"); } - else { - printf(", \"%s\"", list_get(ckl)); + while (list_next(ckl)) { + if (ckl->pos == ckl->size-1) { + printf(", \"%s\" )\n", list_get(ckl)); + } + else { + printf(", \"%s\"", list_get(ckl)); + } } + list_rewind(ckl); } - list_rewind(ckl); } void list_print(cklist *ckl) { - list_rewind(ckl); - while (list_next(ckl)) { - printf("%s\n", list_get(ckl)); + if (ckl->size > 0) { + list_rewind(ckl); + while (list_next(ckl)) { + printf("%s\n", list_get(ckl)); + } + list_rewind(ckl); } - list_rewind(ckl); +} + +int list_size(cklist *ckl) { + return ckl->size; } void list_free(cklist *ckl) { |