[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 2139783: nthcdr now works with bignums
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] master 2139783: nthcdr now works with bignums |
Date: |
Mon, 20 Aug 2018 13:24:46 -0400 (EDT) |
branch: master
commit 21397837eaf0801e7b1cd4155a811a939a7667de
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>
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 a11de1b..aeb9308 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))
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 2139783: nthcdr now works with bignums,
Paul Eggert <=