diff options
Diffstat (limited to 'src/data.c')
| -rw-r--r-- | src/data.c | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/src/data.c b/src/data.c index 4db93f5625f..ccec15f430a 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -2631,30 +2631,16 @@ arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args) | |||
| 2631 | switch (code) | 2631 | switch (code) |
| 2632 | { | 2632 | { |
| 2633 | case Aadd: | 2633 | case Aadd: |
| 2634 | if (INT_ADD_OVERFLOW (accum, next)) | 2634 | overflow |= INT_ADD_WRAPV (accum, next, &accum); |
| 2635 | { | ||
| 2636 | overflow = 1; | ||
| 2637 | accum &= INTMASK; | ||
| 2638 | } | ||
| 2639 | accum += next; | ||
| 2640 | break; | 2635 | break; |
| 2641 | case Asub: | 2636 | case Asub: |
| 2642 | if (INT_SUBTRACT_OVERFLOW (accum, next)) | 2637 | if (! argnum) |
| 2643 | { | 2638 | accum = nargs == 1 ? - next : next; |
| 2644 | overflow = 1; | 2639 | else |
| 2645 | accum &= INTMASK; | 2640 | overflow |= INT_SUBTRACT_WRAPV (accum, next, &accum); |
| 2646 | } | ||
| 2647 | accum = argnum ? accum - next : nargs == 1 ? - next : next; | ||
| 2648 | break; | 2641 | break; |
| 2649 | case Amult: | 2642 | case Amult: |
| 2650 | if (INT_MULTIPLY_OVERFLOW (accum, next)) | 2643 | overflow |= INT_MULTIPLY_WRAPV (accum, next, &accum); |
| 2651 | { | ||
| 2652 | EMACS_UINT a = accum, b = next, ab = a * b; | ||
| 2653 | overflow = 1; | ||
| 2654 | accum = ab & INTMASK; | ||
| 2655 | } | ||
| 2656 | else | ||
| 2657 | accum *= next; | ||
| 2658 | break; | 2644 | break; |
| 2659 | case Adiv: | 2645 | case Adiv: |
| 2660 | if (! (argnum || nargs == 1)) | 2646 | if (! (argnum || nargs == 1)) |
| @@ -2663,7 +2649,10 @@ arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args) | |||
| 2663 | { | 2649 | { |
| 2664 | if (next == 0) | 2650 | if (next == 0) |
| 2665 | xsignal0 (Qarith_error); | 2651 | xsignal0 (Qarith_error); |
| 2666 | accum /= next; | 2652 | if (INT_DIVIDE_OVERFLOW (accum, next)) |
| 2653 | overflow = true; | ||
| 2654 | else | ||
| 2655 | accum /= next; | ||
| 2667 | } | 2656 | } |
| 2668 | break; | 2657 | break; |
| 2669 | case Alogand: | 2658 | case Alogand: |