diff options
| author | Paul Eggert | 2018-08-20 10:24:19 -0700 |
|---|---|---|
| committer | Paul Eggert | 2018-08-20 10:24:42 -0700 |
| commit | 21397837eaf0801e7b1cd4155a811a939a7667de (patch) | |
| tree | 8e61c746ce36383eec6404992b6dddad5d80dde1 /src | |
| parent | ecd7a9407711ebe24d7e07d4402a2d66754ee693 (diff) | |
| download | emacs-21397837eaf0801e7b1cd4155a811a939a7667de.tar.gz emacs-21397837eaf0801e7b1cd4155a811a939a7667de.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fns.c | 15 |
1 files changed, 13 insertions, 2 deletions
| @@ -1402,9 +1402,20 @@ DEFUN ("nthcdr", Fnthcdr, Snthcdr, 2, 2, 0, | |||
| 1402 | doc: /* Take cdr N times on LIST, return the result. */) | 1402 | doc: /* Take cdr N times on LIST, return the result. */) |
| 1403 | (Lisp_Object n, Lisp_Object list) | 1403 | (Lisp_Object n, Lisp_Object list) |
| 1404 | { | 1404 | { |
| 1405 | CHECK_FIXNUM (n); | 1405 | CHECK_INTEGER (n); |
| 1406 | Lisp_Object tail = list; | 1406 | Lisp_Object tail = list; |
| 1407 | for (EMACS_INT num = XFIXNUM (n); 0 < num; num--) | 1407 | |
| 1408 | EMACS_INT num; | ||
| 1409 | if (FIXNUMP (n)) | ||
| 1410 | num = XFIXNUM (n); | ||
| 1411 | else | ||
| 1412 | { | ||
| 1413 | num = mpz_sgn (XBIGNUM (n)->value); | ||
| 1414 | if (0 < num) | ||
| 1415 | num = EMACS_INT_MAX; /* LIST cannot possibly be this long. */ | ||
| 1416 | } | ||
| 1417 | |||
| 1418 | for (; 0 < num; num--) | ||
| 1408 | { | 1419 | { |
| 1409 | if (! CONSP (tail)) | 1420 | if (! CONSP (tail)) |
| 1410 | { | 1421 | { |