diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2020-04-05 01:17:32 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2020-04-05 01:24:36 -0700 |
commit | bec5cfee7660f6e283efbd30a693a6f8e9ea46b8 (patch) | |
tree | b6b872dfb83579336e848a62f720b629426c0ac0 /src/coding.c | |
parent | 9b8dacdb264412b919782920da916e306102262a (diff) | |
download | emacs-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/coding.c')
-rw-r--r-- | src/coding.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/coding.c b/src/coding.c index 0bea2a0c2bc..f0fc37dbdfa 100644 --- a/src/coding.c +++ b/src/coding.c @@ -11061,10 +11061,8 @@ usage: (define-coding-system-internal ...) */) else { CHECK_CONS (val); - CHECK_RANGED_INTEGER (XCAR (val), 0, 255); - from = XFIXNUM (XCAR (val)); - CHECK_RANGED_INTEGER (XCDR (val), from, 255); - to = XFIXNUM (XCDR (val)); + from = check_integer_range (XCAR (val), 0, 255); + to = check_integer_range (XCDR (val), from, 255); } for (int i = from; i <= to; i++) SSET (valids, i, 1); @@ -11149,7 +11147,7 @@ usage: (define-coding-system-internal ...) */) val = XCAR (tail); CHECK_CONS (val); CHECK_CHARSET_GET_ID (XCAR (val), id); - CHECK_RANGED_INTEGER (XCDR (val), 0, 3); + check_integer_range (XCDR (val), 0, 3); XSETCAR (val, make_fixnum (id)); } |