aboutsummaryrefslogtreecommitdiffstats
path: root/src/data.c
diff options
context:
space:
mode:
authorPaul Eggert2018-09-04 19:14:01 -0700
committerPaul Eggert2018-09-04 19:15:57 -0700
commitecb985c10d5241a65ab9552ebfcecaa150b35427 (patch)
treec4f12a76561d84518c597cb8e25cfd3813023456 /src/data.c
parente3661f8c35b3057c58e8c0b474f597697ce413ba (diff)
downloademacs-ecb985c10d5241a65ab9552ebfcecaa150b35427.tar.gz
emacs-ecb985c10d5241a65ab9552ebfcecaa150b35427.zip
Simplify bignum->intmax conversion
* src/lisp.h (integer_to_intmax, integer_to_uintmax): New functions. * src/data.c (cons_to_unsigned, cons_to_signed) (arith_driver): * src/dbusbind.c (xd_extract_signed, xd_extract_unsigned): * src/dispnew.c (sit_for): * src/editfns.c (styled_format): * src/emacs-module.c (module_extract_integer): * src/fileio.c (file_offset): * src/font.c (font_unparse_xlfd, Fopen_font): * src/xdisp.c (calc_line_height_property): * src/process.c (handle_child_signal):
Diffstat (limited to 'src/data.c')
-rw-r--r--src/data.c34
1 files changed, 3 insertions, 31 deletions
diff --git a/src/data.c b/src/data.c
index 7be2052362b..66f69e7e83a 100644
--- a/src/data.c
+++ b/src/data.c
@@ -2653,17 +2653,7 @@ cons_to_unsigned (Lisp_Object c, uintmax_t max)
2653 else 2653 else
2654 { 2654 {
2655 Lisp_Object hi = CONSP (c) ? XCAR (c) : c; 2655 Lisp_Object hi = CONSP (c) ? XCAR (c) : c;
2656 2656 valid = integer_to_uintmax (hi, &val);
2657 if (FIXNUMP (hi))
2658 {
2659 val = XFIXNUM (hi);
2660 valid = 0 <= val;
2661 }
2662 else
2663 {
2664 val = bignum_to_uintmax (hi);
2665 valid = val != 0;
2666 }
2667 2657
2668 if (valid && CONSP (c)) 2658 if (valid && CONSP (c))
2669 { 2659 {
@@ -2724,17 +2714,7 @@ cons_to_signed (Lisp_Object c, intmax_t min, intmax_t max)
2724 else 2714 else
2725 { 2715 {
2726 Lisp_Object hi = CONSP (c) ? XCAR (c) : c; 2716 Lisp_Object hi = CONSP (c) ? XCAR (c) : c;
2727 2717 valid = integer_to_intmax (hi, &val);
2728 if (FIXNUMP (hi))
2729 {
2730 val = XFIXNUM (hi);
2731 valid = true;
2732 }
2733 else if (BIGNUMP (hi))
2734 {
2735 val = bignum_to_intmax (hi);
2736 valid = val != 0;
2737 }
2738 2718
2739 if (valid && CONSP (c)) 2719 if (valid && CONSP (c))
2740 { 2720 {
@@ -2972,16 +2952,8 @@ arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args,
2972 2952
2973 /* Set NEXT to the next value if it fits, else exit the loop. */ 2953 /* Set NEXT to the next value if it fits, else exit the loop. */
2974 intmax_t next; 2954 intmax_t next;
2975 if (FIXNUMP (val)) 2955 if (! (INTEGERP (val) && integer_to_intmax (val, &next)))
2976 next = XFIXNUM (val);
2977 else if (FLOATP (val))
2978 break; 2956 break;
2979 else
2980 {
2981 next = bignum_to_intmax (val);
2982 if (next == 0)
2983 break;
2984 }
2985 2957
2986 /* Set ACCUM to the next operation's result if it fits, 2958 /* Set ACCUM to the next operation's result if it fits,
2987 else exit the loop. */ 2959 else exit the loop. */