/* vi: set sw=4 ts=4: */
-#include "busybox.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#include <math.h>
+#include "busybox.h"
/* Tiny RPN calculator, because "expr" didn't give me bitwise operations. */
static void push(double a)
{
- if (pointer >= (sizeof(stack) / sizeof(*stack))) {
- errorMsg("stack overflow\n");
- exit(-1);
- } else
- stack[pointer++] = a;
+ if (pointer >= (sizeof(stack) / sizeof(*stack)))
+ error_msg_and_die("stack overflow");
+ stack[pointer++] = a;
}
static double pop()
{
- if (pointer == 0) {
- errorMsg("stack underflow\n");
- exit(-1);
- }
+ if (pointer == 0)
+ error_msg_and_die("stack underflow");
return stack[--pointer];
}
}
o++;
}
- errorMsg("%s: syntax error.\n", argument);
- exit(-1);
+ error_msg_and_die("%s: syntax error.", argument);
}
/* return pointer to next token in buffer and set *buffer to one char
}
} else {
if (*argv[1]=='-')
- usage(dc_usage);
+ show_usage();
while (argc >= 2) {
stack_machine(argv[1]);
argv++;
}
}
stack_machine(0);
- return( TRUE);
+ return EXIT_SUCCESS;
}