Soft'N'Design Software
/
projects
/
calc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c91672f
)
correct push
author
Laurent Mazet
<laurent.mazet@thalesgroup.com>
Mon, 13 Feb 2023 11:20:45 +0000
(12:20 +0100)
committer
Laurent Mazet
<laurent.mazet@thalesgroup.com>
Mon, 13 Feb 2023 11:20:45 +0000
(12:20 +0100)
stack.c
patch
|
blob
|
blame
|
history
diff --git
a/stack.c
b/stack.c
index 829f8aa6483f9357861680931a49a54d0a045799..a355fa5e3281b2fc34d1c3460c43701d776c99a2 100644
(file)
--- a/
stack.c
+++ b/
stack.c
@@
-1,3
+1,4
@@
+#include <math.h>
#include <stdio.h>
#include "debug.h"
@@
-30,7
+31,14
@@
double pop ()
double push (double val)
{
- return push_tab (stack, -1, val);
+ double ret = NAN;
+ if (stack) {
+ ret = push_tab (stack, -1, val);
+ } else {
+ stack = resize_tab (stack, 1);
+ ret = set_tab (stack, 1, val);
+ }
+ return ret;
}
double put (int n, double val)