>From 21397837eaf0801e7b1cd4155a811a939a7667de Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 20 Aug 2018 10:24:19 -0700 Subject: [PATCH] nthcdr now works with bignums Problem reported by Karl Fogel in: https://lists.gnu.org/r/emacs-devel/2018-08/msg00671.html * src/fns.c (Fnthcdr): Support bignum counts. --- src/fns.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/fns.c b/src/fns.c index a11de1b082..aeb9308d22 100644 --- a/src/fns.c +++ b/src/fns.c @@ -1402,9 +1402,20 @@ DEFUN ("nthcdr", Fnthcdr, Snthcdr, 2, 2, 0, doc: /* Take cdr N times on LIST, return the result. */) (Lisp_Object n, Lisp_Object list) { - CHECK_FIXNUM (n); + CHECK_INTEGER (n); Lisp_Object tail = list; - for (EMACS_INT num = XFIXNUM (n); 0 < num; num--) + + EMACS_INT num; + if (FIXNUMP (n)) + num = XFIXNUM (n); + else + { + num = mpz_sgn (XBIGNUM (n)->value); + if (0 < num) + num = EMACS_INT_MAX; /* LIST cannot possibly be this long. */ + } + + for (; 0 < num; num--) { if (! CONSP (tail)) { -- 2.17.1