Mercurial > hg > xemacs-beta
diff src/bytecode.c @ 5300:9f738305f80f
Accept sequences generally, not just lists, #'reverse, #'nreverse.
src/ChangeLog addition:
2010-11-06 Aidan Kehoe <kehoea@parhasard.net>
* bytecode.c (bytecode_nreverse): Call Fnreverse() if SEQUENCE is
not a cons in this function.
(Fnreverse, Freverse):
Accept sequences, not just lists, in these functions.
man/ChangeLog addition:
2010-11-06 Aidan Kehoe <kehoea@parhasard.net>
* lispref/lists.texi (Rearrangement, Building Lists):
Document that #'nreverse and #'reverse now accept sequences, not
just lists, in this file.
tests/ChangeLog addition:
2010-11-06 Aidan Kehoe <kehoea@parhasard.net>
* automated/lisp-tests.el (list-nreverse):
Check that #'reverse and #'nreverse handle non-list sequences
properly.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sat, 06 Nov 2010 21:18:52 +0000 |
parents | 39d74978fd32 |
children | c096d8051f89 46491edfd94a |
line wrap: on
line diff
--- a/src/bytecode.c Sat Nov 06 14:51:13 2010 +0000 +++ b/src/bytecode.c Sat Nov 06 21:18:52 2010 +0000 @@ -251,21 +251,28 @@ } static Lisp_Object -bytecode_nreverse (Lisp_Object list) +bytecode_nreverse (Lisp_Object sequence) { - REGISTER Lisp_Object prev = Qnil; - REGISTER Lisp_Object tail = list; - - while (!NILP (tail)) + if (LISTP (sequence)) { - REGISTER Lisp_Object next; - CHECK_CONS (tail); - next = XCDR (tail); - XCDR (tail) = prev; - prev = tail; - tail = next; + REGISTER Lisp_Object prev = Qnil; + REGISTER Lisp_Object tail = sequence; + + while (!NILP (tail)) + { + REGISTER Lisp_Object next; + CHECK_CONS (tail); + next = XCDR (tail); + XCDR (tail) = prev; + prev = tail; + tail = next; + } + return prev; } - return prev; + else + { + return Fnreverse (sequence); + } }