From 3e6ede0be774cdf21680fe65c3c40ca7e19ce843 Mon Sep 17 00:00:00 2001 From: jcmdln Date: Sat, 23 Sep 2023 13:03:45 -0400 Subject: [PATCH] Normalize conditional style --- src/core.c | 5 ++++- src/printer.c | 5 ++++- src/reader.c | 5 ++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/core.c b/src/core.c index 50310f6..19531c7 100644 --- a/src/core.c +++ b/src/core.c @@ -100,7 +100,10 @@ Reverse(Object const *const object) Object const *reversed = &NIL; while (head->type == TYPE_LIST) { Object const *car = Car(head); - reversed = (car->type == TYPE_LIST) ? Cons(Reverse(car), reversed) : Cons(car, reversed); + if (car->type == TYPE_LIST) + reversed = Cons(Reverse(car), reversed); + else + reversed = Cons(car, reversed); head = Cdr(head); } return reversed; diff --git a/src/printer.c b/src/printer.c index 7aa76e2..297cbae 100644 --- a/src/printer.c +++ b/src/printer.c @@ -18,7 +18,10 @@ printer(Object const *object) printf("nil"); break; case TYPE_BOOLEAN: - printf(object->boolean ? "true" : "false"); + if (object->boolean) + printf("true"); + else + printf("false"); break; case TYPE_ERROR: printf("error: %s\n", object->string); diff --git a/src/reader.c b/src/reader.c index 324d70d..f42cae2 100644 --- a/src/reader.c +++ b/src/reader.c @@ -41,11 +41,10 @@ read_delimiters(char const *const input, char const begin, char const end) int64_t balanced = 0; do { - if (*cursor == begin) { + if (*cursor == begin) ++balanced; - } else if (*cursor == end) { + else if (*cursor == end) --balanced; - } } while (*++cursor); if (balanced < 0) return Error("read_delimiters: missing begin");