summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGerrit Pape <pape@smarden.org>2007-12-23 21:24:37 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2007-12-23 21:24:37 +0800
commit469fad86703e8dc8177dc9f1a768571105292344 (patch)
treeb1a9ba02237d1d960b22ef7e2b24e0a7c1f67687 /src
parent[BUILTIN] Add set +o support (diff)
downloaddash-469fad86703e8dc8177dc9f1a768571105292344.tar.gz
dash-469fad86703e8dc8177dc9f1a768571105292344.zip
[ARITH] If imaxdiv() isn't available, use / and % operators
Although in posix, imaxdiv() isn't implemented on Debian/alpha, causing
dash to fail to build.  So use / and % operators if imaxdiv() isn't
available.

 http://bugs.debian.org/456398

Signed-off-by: Gerrit Pape <pape@smarden.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'src')
-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:
it/txt/music.txt?id=b45dbe2cd833995a87cb9c1cdcd5dead3d4ad17f&follow=1'>Add "Come On Petunia"June McEnroe 2020-11-13Add x4 to LESSJune McEnroe 2020-11-04Remove modified sensitivity settingsJune McEnroe 2020-10-29Remove editJune McEnroe 2020-10-27Switch gr alias back to git rebaseJune McEnroe 2020-10-27Allow cd host: to cd to same path over sshJune McEnroe 2020-10-27Use SendEnv for cd host:pathJune McEnroe 2020-10-27Allow cd host:path over sshJune McEnroe 2020-10-07Use mandoc -T utf8 for text.June McEnroe 2020-09-20Add The Awakened KingdomJune McEnroe 2020-09-12Move /opt/local back, cheat port select to use system manJune McEnroe 2020-09-12Move /opt/local behind /usr againJune McEnroe 2020-09-12Enable toc in cgit renderings of man pagesJune McEnroe 2020-09-11Install mandoc on macOSJune McEnroe 2020-09-11Rewrite install script yet againJune McEnroe 2020-09-11Remove NetBSD from install scriptJune McEnroe 2020-09-11Use MacPorts rather than pkgsrcJune McEnroe 2020-09-11Add debian VM name to sshJune McEnroe 2020-09-11Add influencer tweetJune McEnroe 2020-09-10Add The Kingdom of GodsJune McEnroe 2020-09-07Add SunglassesJune McEnroe 2020-09-06Add Between the BreathsJune McEnroe 2020-09-04Open /dev/tty in nudgeJune McEnroe 2020-09-04Add nudgeJune McEnroe 2020-09-03Build fbclock with -lzJune McEnroe 2020-08-29Add tweets from retweetsJune McEnroe