1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-25 23:10:47 -08:00

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.
This commit is contained in:
Paul Eggert 2020-04-05 01:17:32 -07:00
parent 9b8dacdb26
commit bec5cfee76
16 changed files with 158 additions and 205 deletions

View file

@ -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));
}