From f06c261e81f322ea17dc7001a1ceb49537b782f7 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Sun, 19 Feb 2023 17:54:34 -0800 Subject: [PATCH] Let's use the idiomatic functions, eh? That way the code is simpler and there aren't error messages scattered all over the place. --- implementations/C/joy.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/implementations/C/joy.c b/implementations/C/joy.c index f46fef7..bf7d3e5 100644 --- a/implementations/C/joy.c +++ b/implementations/C/joy.c @@ -294,17 +294,13 @@ void fn(JoyListPtr stack, __attribute__((unused)) JoyListPtr expression) { JoyList s1 = pop_list(stack); + JoyListPtr s1Ptr = &s1; mpz_t *i1 = pop_int(stack); JoyList node = newIntNode(); mpz_set(node->head->value.i, *i1); - while (s1) { - if (joyInt == s1->head->kind) { - mpz_add(node->head->value.i, node->head->value.i, s1->head->value.i); - s1 = s1->tail; - } else { - fprintf(stderr, "Not an integer.\n"); - longjmp(jbuf, 1); - } + while (*s1Ptr) { + i1 = pop_int(s1Ptr); + mpz_add(node->head->value.i, node->head->value.i, *i1); } node->tail = *stack; *stack = node;