summaryrefslogtreecommitdiff
path: root/src/search.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2020-04-05 01:17:32 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2020-04-05 01:24:36 -0700
commitbec5cfee7660f6e283efbd30a693a6f8e9ea46b8 (patch)
treeb6b872dfb83579336e848a62f720b629426c0ac0 /src/search.c
parent9b8dacdb264412b919782920da916e306102262a (diff)
downloademacs-bec5cfee7660f6e283efbd30a693a6f8e9ea46b8.tar.gz
Improve integer range checking
* src/bignum.c (check_integer_range, check_uinteger_max) (check_int_nonnegative): New functions. * src/frame.c (check_frame_pixels): New function. (Fset_frame_height, Fset_frame_width, Fset_frame_size): Use it. * src/lisp.h (CHECK_RANGED_INTEGER, CHECK_TYPE_RANGED_INTEGER): Remove these macros. Unless otherwise specified, all callers replaced by calls to check_integer_range, check_uinteger_range, check_int_nonnegative. * src/frame.c (gui_set_right_divider_width) (gui_set_bottom_divider_width): * src/nsfns.m (ns_set_internal_border_width): * src/xfns.c (x_set_internal_border_width): Using check_int_nonnegative means these functions no longer incorrectly reject negative bignums; they treat them as 0, just like negative fixnums.
Diffstat (limited to 'src/search.c')
-rw-r--r--src/search.c9
1 files changed, 1 insertions, 8 deletions
diff --git a/src/search.c b/src/search.c
index 7389fbef0ee..08b57c5faf3 100644
--- a/src/search.c
+++ b/src/search.c
@@ -2392,14 +2392,7 @@ since only regular expressions have distinguished subexpressions. */)
if (num_regs <= 0)
error ("`replace-match' called before any match found");
- if (NILP (subexp))
- sub = 0;
- else
- {
- CHECK_RANGED_INTEGER (subexp, 0, num_regs - 1);
- sub = XFIXNUM (subexp);
- }
-
+ sub = !NILP (subexp) ? check_integer_range (subexp, 0, num_regs - 1) : 0;
ptrdiff_t sub_start = search_regs.start[sub];
ptrdiff_t sub_end = search_regs.end[sub];
eassert (sub_start <= sub_end);