summaryrefslogtreecommitdiff
path: root/src/json.c
diff options
context:
space:
mode:
authorPhilipp Stephani <phst@google.com>2019-04-22 17:29:06 +0200
committerPhilipp Stephani <phst@google.com>2019-04-22 17:36:52 +0200
commit4e2ea400cbd78fa791fb897938a6dcb099401a25 (patch)
treebf386a4685abccf8ffc6ad6cf907e18671f0f405 /src/json.c
parent3b4e312cfe1e0b185fea58bc35fa951a8389c144 (diff)
downloademacs-4e2ea400cbd78fa791fb897938a6dcb099401a25.tar.gz
emacs-4e2ea400cbd78fa791fb897938a6dcb099401a25.tar.bz2
emacs-4e2ea400cbd78fa791fb897938a6dcb099401a25.zip
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.
Diffstat (limited to 'src/json.c')
-rw-r--r--src/json.c9
1 files changed, 1 insertions, 8 deletions
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))