aboutsummaryrefslogtreecommitdiffstats
path: root/src/cklist.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2018-05-08 16:44:05 +0300
committergramanas <anastasis.gramm2@gmail.com>2018-05-08 16:44:05 +0300
commitfb7e3e1352aeca03909ae3720c8cae90fcd57186 (patch)
tree73ec2c99e3a8c578c1791e83a5ec74749a8316af /src/cklist.c
parent00faacfa1ba2af7dd6dbd441e0ede57029d92686 (diff)
downloadck-fb7e3e1352aeca03909ae3720c8cae90fcd57186.tar.gz
ck-fb7e3e1352aeca03909ae3720c8cae90fcd57186.tar.bz2
ck-fb7e3e1352aeca03909ae3720c8cae90fcd57186.zip
user args an now cklist type
Diffstat (limited to 'src/cklist.c')
-rw-r--r--src/cklist.c35
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) {