diff options
| author | Paul Eggert | 2018-09-04 19:14:01 -0700 |
|---|---|---|
| committer | Paul Eggert | 2018-09-04 19:15:57 -0700 |
| commit | ecb985c10d5241a65ab9552ebfcecaa150b35427 (patch) | |
| tree | c4f12a76561d84518c597cb8e25cfd3813023456 /src/dbusbind.c | |
| parent | e3661f8c35b3057c58e8c0b474f597697ce413ba (diff) | |
| download | emacs-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/dbusbind.c')
| -rw-r--r-- | src/dbusbind.c | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/src/dbusbind.c b/src/dbusbind.c index 47346a7d4d4..9bc344e9612 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c | |||
| @@ -520,12 +520,13 @@ static intmax_t | |||
| 520 | xd_extract_signed (Lisp_Object x, intmax_t lo, intmax_t hi) | 520 | xd_extract_signed (Lisp_Object x, intmax_t lo, intmax_t hi) |
| 521 | { | 521 | { |
| 522 | CHECK_NUMBER (x); | 522 | CHECK_NUMBER (x); |
| 523 | if (FIXNUMP (x)) | 523 | if (INTEGERP (x)) |
| 524 | { | 524 | { |
| 525 | if (lo <= XFIXNUM (x) && XFIXNUM (x) <= hi) | 525 | intmax_t i; |
| 526 | return XFIXNUM (x); | 526 | if (integer_to_intmax (x, &i) && lo <= i && i <= hi) |
| 527 | return i; | ||
| 527 | } | 528 | } |
| 528 | else if (FLOATP (x)) | 529 | else |
| 529 | { | 530 | { |
| 530 | double d = XFLOAT_DATA (x); | 531 | double d = XFLOAT_DATA (x); |
| 531 | if (lo <= d && d < 1.0 + hi) | 532 | if (lo <= d && d < 1.0 + hi) |
| @@ -535,12 +536,6 @@ xd_extract_signed (Lisp_Object x, intmax_t lo, intmax_t hi) | |||
| 535 | return n; | 536 | return n; |
| 536 | } | 537 | } |
| 537 | } | 538 | } |
| 538 | else if (! (MOST_NEGATIVE_FIXNUM <= lo && hi <= MOST_POSITIVE_FIXNUM)) | ||
| 539 | { | ||
| 540 | intmax_t i = bignum_to_intmax (x); | ||
| 541 | if (i != 0 && lo <= i && i <= hi) | ||
| 542 | return i; | ||
| 543 | } | ||
| 544 | 539 | ||
| 545 | if (xd_in_read_queued_messages) | 540 | if (xd_in_read_queued_messages) |
| 546 | Fthrow (Qdbus_error, Qnil); | 541 | Fthrow (Qdbus_error, Qnil); |
| @@ -553,12 +548,13 @@ static uintmax_t | |||
| 553 | xd_extract_unsigned (Lisp_Object x, uintmax_t hi) | 548 | xd_extract_unsigned (Lisp_Object x, uintmax_t hi) |
| 554 | { | 549 | { |
| 555 | CHECK_NUMBER (x); | 550 | CHECK_NUMBER (x); |
| 556 | if (FIXNUMP (x)) | 551 | if (INTEGERP (x)) |
| 557 | { | 552 | { |
| 558 | if (0 <= XFIXNUM (x) && XFIXNUM (x) <= hi) | 553 | uintmax_t i; |
| 559 | return XFIXNUM (x); | 554 | if (integer_to_uintmax (x, &i) && i <= hi) |
| 555 | return i; | ||
| 560 | } | 556 | } |
| 561 | else if (FLOATP (x)) | 557 | else |
| 562 | { | 558 | { |
| 563 | double d = XFLOAT_DATA (x); | 559 | double d = XFLOAT_DATA (x); |
| 564 | if (0 <= d && d < 1.0 + hi) | 560 | if (0 <= d && d < 1.0 + hi) |
| @@ -568,12 +564,6 @@ xd_extract_unsigned (Lisp_Object x, uintmax_t hi) | |||
| 568 | return n; | 564 | return n; |
| 569 | } | 565 | } |
| 570 | } | 566 | } |
| 571 | else if (! (hi <= MOST_POSITIVE_FIXNUM)) | ||
| 572 | { | ||
| 573 | uintmax_t i = bignum_to_uintmax (x); | ||
| 574 | if (i != 0 && i <= hi) | ||
| 575 | return i; | ||
| 576 | } | ||
| 577 | 567 | ||
| 578 | if (xd_in_read_queued_messages) | 568 | if (xd_in_read_queued_messages) |
| 579 | Fthrow (Qdbus_error, Qnil); | 569 | Fthrow (Qdbus_error, Qnil); |