From 4e2ea400cbd78fa791fb897938a6dcb099401a25 Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Mon, 22 Apr 2019 17:29:06 +0200 Subject: Introduce a helper macro to convert a Lisp integer to a C integer. This is similar to CONS_TO_INTEGER. The inverse (INT_TO_INTEGER) already exists. * src/lisp.h (INTEGER_TO_INT): New macro. (ranged_integer_to_int, ranged_integer_to_uint): New functions. * src/json.c (lisp_to_json): Use helper macro. --- src/json.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'src/json.c') diff --git a/src/json.c b/src/json.c index 928825e034c..16500bce72d 100644 --- a/src/json.c +++ b/src/json.c @@ -495,14 +495,7 @@ lisp_to_json (Lisp_Object lisp, struct json_configuration *conf) else if (EQ (lisp, Qt)) return json_check (json_true ()); else if (INTEGERP (lisp)) - { - intmax_t low = TYPE_MINIMUM (json_int_t); - intmax_t high = TYPE_MAXIMUM (json_int_t); - intmax_t value; - if (! integer_to_intmax (lisp, &value) || value < low || high < value) - args_out_of_range_3 (lisp, make_int (low), make_int (high)); - return json_check (json_integer (value)); - } + return json_check (json_integer (INTEGER_TO_INT (lisp, json_int_t))); else if (FLOATP (lisp)) return json_check (json_real (XFLOAT_DATA (lisp))); else if (STRINGP (lisp)) -- cgit v1.2.3