From 48d7720993283a3387807fa5582bb10b1636bba5 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 9 Dec 2018 17:07:16 -0800 Subject: [PATCH] Remove CHECK_FIXNUM_CAR etc. * src/coding.c (CHECK_FIXNAT_CAR, CHECK_FIXNAT_CDR): * src/lisp.h (CHECK_FIXNUM_CAR, CHECK_FIXNUM_CDR): Remove. All uses removed. These seem to have been based on the assumption that the argument cons needs to be modified, an assumption that is incorrect for fixnums. (Fdefine_coding_system_internal): Use CHECK_RANGED_INTEGER instead of a special diagnostic for graphic register numbers. --- src/coding.c | 41 +++++++---------------------------------- src/indent.c | 12 ++++++------ src/lisp.h | 18 ------------------ src/w32proc.c | 4 ++-- 4 files changed, 15 insertions(+), 60 deletions(-) diff --git a/src/coding.c b/src/coding.c index 398691fc864..c2945707e23 100644 --- a/src/coding.c +++ b/src/coding.c @@ -617,23 +617,7 @@ inhibit_flag (int encoded_flag, bool var) do { \ (attrs) = CODING_ID_ATTRS ((coding)->id); \ (charset_list) = CODING_ATTR_CHARSET_LIST (attrs); \ - } while (0) - -static void -CHECK_FIXNAT_CAR (Lisp_Object x) -{ - Lisp_Object tmp = XCAR (x); - CHECK_FIXNAT (tmp); - XSETCAR (x, tmp); -} - -static void -CHECK_FIXNAT_CDR (Lisp_Object x) -{ - Lisp_Object tmp = XCDR (x); - CHECK_FIXNAT (tmp); - XSETCDR (x, tmp); -} + } while (false) /* True if CODING's destination can be grown. */ @@ -10271,15 +10255,9 @@ usage: (define-coding-system-internal ...) */) else { CHECK_CONS (val); - CHECK_FIXNAT_CAR (val); - CHECK_FIXNUM_CDR (val); - if (XFIXNUM (XCAR (val)) > 255) - args_out_of_range_3 (XCAR (val), - make_fixnum (0), make_fixnum (255)); + CHECK_RANGED_INTEGER (XCAR (val), 0, 255); from = XFIXNUM (XCAR (val)); - if (! (from <= XFIXNUM (XCDR (val)) && XFIXNUM (XCDR (val)) <= 255)) - args_out_of_range_3 (XCDR (val), - XCAR (val), make_fixnum (255)); + CHECK_RANGED_INTEGER (XCDR (val), from, 255); to = XFIXNUM (XCDR (val)); } for (int i = from; i <= to; i++) @@ -10354,23 +10332,18 @@ usage: (define-coding-system-internal ...) */) reg_usage = args[coding_arg_iso2022_reg_usage]; CHECK_CONS (reg_usage); - CHECK_FIXNUM_CAR (reg_usage); - CHECK_FIXNUM_CDR (reg_usage); + CHECK_FIXNUM (XCAR (reg_usage)); + CHECK_FIXNUM (XCDR (reg_usage)); request = Fcopy_sequence (args[coding_arg_iso2022_request]); for (Lisp_Object tail = request; CONSP (tail); tail = XCDR (tail)) { int id; - Lisp_Object tmp1; val = XCAR (tail); CHECK_CONS (val); - tmp1 = XCAR (val); - CHECK_CHARSET_GET_ID (tmp1, id); - CHECK_FIXNAT_CDR (val); - if (XFIXNUM (XCDR (val)) >= 4) - error ("Invalid graphic register number: %"pI"d", - XFIXNUM (XCDR (val))); + CHECK_CHARSET_GET_ID (XCAR (val), id); + CHECK_RANGED_INTEGER (XCDR (val), 0, 3); XSETCAR (val, make_fixnum (id)); } diff --git a/src/indent.c b/src/indent.c index 18855768d37..8761388b856 100644 --- a/src/indent.c +++ b/src/indent.c @@ -1756,14 +1756,14 @@ visible section of the buffer, and pass LINE and COL as TOPOS. */) CHECK_FIXNUM_COERCE_MARKER (from); CHECK_CONS (frompos); - CHECK_FIXNUM_CAR (frompos); - CHECK_FIXNUM_CDR (frompos); + CHECK_FIXNUM (XCAR (frompos)); + CHECK_FIXNUM (XCDR (frompos)); CHECK_FIXNUM_COERCE_MARKER (to); if (!NILP (topos)) { CHECK_CONS (topos); - CHECK_FIXNUM_CAR (topos); - CHECK_FIXNUM_CDR (topos); + CHECK_FIXNUM (XCAR (topos)); + CHECK_FIXNUM (XCDR (topos)); } if (!NILP (width)) CHECK_FIXNUM (width); @@ -1771,8 +1771,8 @@ visible section of the buffer, and pass LINE and COL as TOPOS. */) if (!NILP (offsets)) { CHECK_CONS (offsets); - CHECK_FIXNUM_CAR (offsets); - CHECK_FIXNUM_CDR (offsets); + CHECK_FIXNUM (XCAR (offsets)); + CHECK_FIXNUM (XCDR (offsets)); if (! (0 <= XFIXNUM (XCAR (offsets)) && XFIXNUM (XCAR (offsets)) <= PTRDIFF_MAX && 0 <= XFIXNUM (XCDR (offsets)) && XFIXNUM (XCDR (offsets)) <= INT_MAX)) args_out_of_range (XCAR (offsets), XCDR (offsets)); diff --git a/src/lisp.h b/src/lisp.h index 3943bf63ee7..bda848430a2 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -2906,24 +2906,6 @@ CHECK_INTEGER (Lisp_Object x) else \ CHECK_TYPE (INTEGERP (x), Qnumber_or_marker_p, x); \ } while (false) - -/* Since we can't assign directly to the CAR or CDR fields of a cons - cell, use these when checking that those fields contain numbers. */ -INLINE void -CHECK_FIXNUM_CAR (Lisp_Object x) -{ - Lisp_Object tmp = XCAR (x); - CHECK_FIXNUM (tmp); - XSETCAR (x, tmp); -} - -INLINE void -CHECK_FIXNUM_CDR (Lisp_Object x) -{ - Lisp_Object tmp = XCDR (x); - CHECK_FIXNUM (tmp); - XSETCDR (x, tmp); -} /* Define a built-in function for calling from Lisp. `lname' should be the name to give the function in Lisp, diff --git a/src/w32proc.c b/src/w32proc.c index cb02ba63412..5a075ff1a9a 100644 --- a/src/w32proc.c +++ b/src/w32proc.c @@ -3476,8 +3476,8 @@ If successful, the new layout id is returned, otherwise nil. */) HKL kl; CHECK_CONS (layout); - CHECK_FIXNUM_CAR (layout); - CHECK_FIXNUM_CDR (layout); + CHECK_FIXNUM (XCAR (layout)); + CHECK_FIXNUM (XCDR (layout)); kl = (HKL) (UINT_PTR) ((XFIXNUM (XCAR (layout)) & 0xffff) | (XFIXNUM (XCDR (layout)) << 16)); -- 2.39.2