fixed -Wall warnings
parent
115b8f8132
commit
13cc6ee019
|
@ -37,15 +37,19 @@ double val[MAXVAL];
|
||||||
/* length: current length of stack */
|
/* length: current length of stack */
|
||||||
#define length() sp
|
#define length() sp
|
||||||
/* push: push f onto value stack */
|
/* push: push f onto value stack */
|
||||||
#define push(x) ((sp < MAXVAL) ? val[sp++] = (x) : printerr(FULL_STACK_ERR, ((double) (x))))
|
#define push(x) \
|
||||||
|
((sp < MAXVAL) ? val[sp++] = x : printerr(FULL_STACK_ERR, (double) (x)))
|
||||||
/* pop: pop and return top value from stack */
|
/* pop: pop and return top value from stack */
|
||||||
#define pop() (sp ? val[--sp] : (printerr(EMPTY_STACK_ERR), 0))
|
double pop(void)
|
||||||
|
{
|
||||||
|
return sp ? val[--sp] : (printerr(EMPTY_STACK_ERR), 0);
|
||||||
|
}
|
||||||
/* peek: return top value from stack, leave stack unchanged */
|
/* peek: return top value from stack, leave stack unchanged */
|
||||||
#define peek() (sp ? val[sp-1] : (printerr(EMPTY_STACK_ERR), 0))
|
#define peek() (sp ? val[sp-1] : (printerr(EMPTY_STACK_ERR), 0))
|
||||||
/* clear: clear stack */
|
/* clear: clear stack */
|
||||||
#define clear() (sp = 0)
|
#define clear() (sp = 0)
|
||||||
/* dup: duplicate top element */
|
/* dup: duplicate top element */
|
||||||
#define dup() push(peek())
|
#define dup() do { double tmp = peek(); push(tmp); } while (0)
|
||||||
/* swap: swap top two elements */
|
/* swap: swap top two elements */
|
||||||
#define swap() \
|
#define swap() \
|
||||||
do { if (sp < 2) printerr(SHORT_STACK_ERR); else { \
|
do { if (sp < 2) printerr(SHORT_STACK_ERR); else { \
|
||||||
|
@ -203,7 +207,7 @@ int main()
|
||||||
int t_len;
|
int t_len;
|
||||||
|
|
||||||
printf(INITIAL_PROMPT_F);
|
printf(INITIAL_PROMPT_F);
|
||||||
while (t_len = gettoken(token, MAXTOKEN)) {
|
while ((t_len = gettoken(token, MAXTOKEN))) {
|
||||||
if (t_len < 0) { /* newline token */
|
if (t_len < 0) { /* newline token */
|
||||||
if (length())
|
if (length())
|
||||||
print_pop();
|
print_pop();
|
||||||
|
|
Loading…
Reference in New Issue