-#define arithf(name, op) \
-static \
-int name (l, r) VALUE *l; VALUE *r; \
-{ \
- if (!toarith (l) || !toarith (r)) \
- error_msg_and_die ("non-numeric argument"); \
- return l->u.i op r->u.i; \
-}
-
-#define arithdivf(name, op) \
-static int name (l, r) VALUE *l; VALUE *r; \
-{ \
- if (!toarith (l) || !toarith (r)) \
- error_msg_and_die ( "non-numeric argument"); \
- if (r->u.i == 0) \
- error_msg_and_die ( "division by zero"); \
- return l->u.i op r->u.i; \
+static arith_t arithmetic_common (VALUE *l, VALUE *r, int op)
+{
+ arith_t li, ri;
+
+ if (!toarith (l) || !toarith (r))
+ bb_error_msg_and_die ("non-numeric argument");
+ li = l->u.i;
+ ri = r->u.i;
+ if((op == '/' || op == '%') && ri == 0)
+ bb_error_msg_and_die ( "division by zero");
+ switch(op) {
+ case '+':
+ return li + ri;
+ case '-':
+ return li - ri;
+ case '*':
+ return li * ri;
+ case '/':
+ return li / ri;
+ default:
+ return li % ri;
+ }