From d71d7dc9583e96a20c568c1929cbc137516e48ce Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 7 Nov 2021 00:11:17 +0100 Subject: dont error on stack limit --- main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index c369290..b4e7b48 100644 --- a/main.c +++ b/main.c @@ -37,7 +37,6 @@ int main() { fprintf(s.defout, s.prompt, s.command_count, s.last_op); s.last_op = 0; char *endptr = NULL; - if (s.stk.count == STACK_SIZE) errx(1, "exceeded stk size"); fgets(buf, BUF_SIZE, s.defbuf); buf[strcspn(buf, "\n")] = 0; double interpreted = strtod(buf, &endptr); @@ -84,6 +83,10 @@ int main() { } else exec(buf, &s); } } else { /* we found a number */ + if (s.stk.count == STACK_SIZE - 1) { + fprintf(s.defout, "exceeded stack size %d\n", STACK_SIZE); + continue; + } s.stk.val[s.stk.count++] = interpreted; } -- cgit 1.4.1-2-gfad0