Skip to content

Commit

Permalink
Normalize conditional style
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmdln committed Sep 23, 2023
1 parent 5329634 commit 3e6ede0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion src/printer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions src/reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 3e6ede0

Please sign in to comment.