Soft'N'Design Software
/
projects
/
calc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
change perl program calls
[calc.git]
/
stack.c
diff --git
a/stack.c
b/stack.c
index 829f8aa6483f9357861680931a49a54d0a045799..081023fa985c4d7f3d097e7483662c04096d59a3 100644
(file)
--- a/
stack.c
+++ b/
stack.c
@@
-1,3
+1,4
@@
+#include <math.h>
#include <stdio.h>
#include "debug.h"
#include <stdio.h>
#include "debug.h"
@@
-30,7
+31,14
@@
double pop ()
double push (double val)
{
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)
}
double put (int n, double val)
@@
-116,12
+124,7
@@
double min ()
void order ()
{
void order ()
{
- int n = size_tab (stack);
- if (n < 3) {
- VERBOSE (WARNING, fprintf (stdout, "error not enough element in stack (%d)\n", n));
- } else {
- order_tab (stack);
- }
+ order_tab (stack);
}
double median ()
}
double median ()