diff options
author | Daniel <steew0x8@protonmail.com> | 2021-11-07 00:11:17 +0100 |
---|---|---|
committer | Daniel <steew0x8@protonmail.com> | 2021-11-07 00:11:17 +0100 |
commit | d71d7dc9583e96a20c568c1929cbc137516e48ce (patch) | |
tree | b1d9002132544546dced27b9396dae1dcc46904f | |
parent | 65b783d28ec01e8ed4ee8de0ae3180f6850a5a5b (diff) | |
download | rpncalc-d71d7dc9583e96a20c568c1929cbc137516e48ce.tar.gz |
dont error on stack limit
-rw-r--r-- | main.c | 5 |
1 files changed, 4 insertions, 1 deletions
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; } |