static void push(double a)
{
if (pointer >= (sizeof(stack) / sizeof(*stack)))
- error_msg_and_die("stack overflow");
+ bb_error_msg_and_die("stack overflow");
stack[pointer++] = a;
}
static double pop(void)
{
if (pointer == 0)
- error_msg_and_die("stack underflow");
+ bb_error_msg_and_die("stack underflow");
return stack[--pointer];
}
push(pop() * pop());
}
+static void power(void)
+{
+ double topower = pop();
+
+ push(pow(pop(), topower));
+}
+
static void divide(void)
{
double divisor = pop();
push(pop() / divisor);
}
+static void mod(void)
+{
+ unsigned int d = pop();
+
+ push((unsigned int) pop() % d);
+}
+
static void and(void)
{
push((unsigned int) pop() & (unsigned int) pop());
{"mul", mul},
{"/", divide},
{"div", divide},
+ {"**", power},
+ {"exp", power},
+ {"pow", power},
+ {"%", mod},
+ {"mod", mod},
{"and", and},
{"or", or},
{"not", not},
{"eor", eor},
+ {"xor", eor},
{"p", print_no_pop},
{"f", print_stack_no_pop},
{"o", set_output_base},
}
o++;
}
- error_msg_and_die("%s: syntax error.", argument);
+ bb_error_msg_and_die("%s: syntax error.", argument);
}
/* return pointer to next token in buffer and set *buffer to one char
while (isspace(*current)) { current++; }
if (*current != 0) {
start = current;
- while (!isspace(*current) && current != 0) { current++; }
+ while (!isspace(*current) && *current != 0) { current++; }
*buffer = current;
}
return start;
char *line = NULL;
char *cursor = NULL;
char *token = NULL;
- while ((line = get_line_from_file(stdin))) {
+ while ((line = bb_get_chomped_line_from_file(stdin))) {
cursor = line;
len = number_of_tokens(line);
for (i = 0; i < len; i++) {
}
} else {
if (*argv[1]=='-')
- show_usage();
+ bb_show_usage();
while (argc >= 2) {
stack_machine(argv[1]);
argv++;