From: Paul Eggert Date: Mon, 20 Aug 2018 17:24:19 +0000 (-0700) Subject: nthcdr now works with bignums X-Git-Tag: emacs-27.0.90~4535 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=21397837eaf0801e7b1cd4155a811a939a7667de;p=emacs.git 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. --- diff --git a/src/fns.c b/src/fns.c index a11de1b0827..aeb9308d227 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)) {