summary refs log tree commit diff
path: root/src/arith_yacc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arith_yacc.c')
-rw-r--r--src/arith_yacc.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/arith_yacc.c b/src/arith_yacc.c
index e473594..f4857fe 100644
--- a/src/arith_yacc.c
+++ b/src/arith_yacc.c
@@ -88,7 +88,9 @@ static inline int higher_prec(int op1, int op2)
 
 static intmax_t do_binop(int op, intmax_t a, intmax_t b)
 {
+#ifdef HAVE_IMAXDIV
 	imaxdiv_t div;
+#endif
 
 	switch (op) {
 	default:
@@ -96,8 +98,12 @@ static intmax_t do_binop(int op, intmax_t a, intmax_t b)
 	case ARITH_DIV:
 		if (!b)
 			yyerror("division by zero");
+#ifdef HAVE_IMAXDIV
 		div = imaxdiv(a, b);
 		return op == ARITH_REM ? div.rem : div.quot;
+#else
+		return op == ARITH_REM ? a % b : a / b;
+#endif
 	case ARITH_MUL:
 		return a * b;
 	case ARITH_ADD: