Mercurial > hg > xemacs-beta
changeset 5299:28651c24b3f8
Error in #'list-length if LIST is dotted; check for this error with #'mapcar
src/ChangeLog addition:
2010-11-06 Aidan Kehoe <kehoea@parhasard.net>
* fns.c (Flist_length): Error if LIST is dotted in this function;
document this behaviour.
tests/ChangeLog addition:
2010-11-06 Aidan Kehoe <kehoea@parhasard.net>
* automated/lisp-tests.el (malformed-list): Check that #'mapcar,
#'map and #'list-length throw this error when appropriate.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sat, 06 Nov 2010 14:51:13 +0000 |
parents | 99006e0b3a84 |
children | 9f738305f80f |
files | src/ChangeLog src/fns.c tests/ChangeLog tests/automated/lisp-tests.el |
diffstat | 4 files changed, 22 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Tue Nov 02 20:19:39 2010 +0100 +++ b/src/ChangeLog Sat Nov 06 14:51:13 2010 +0000 @@ -1,3 +1,8 @@ +2010-11-06 Aidan Kehoe <kehoea@parhasard.net> + + * fns.c (Flist_length): Error if LIST is dotted in this function; + document this behaviour. + 2010-10-25 Aidan Kehoe <kehoea@parhasard.net> * specifier.c (specifier_instance_from_inst_list):
--- a/src/fns.c Tue Nov 02 20:19:39 2010 +0100 +++ b/src/fns.c Sat Nov 06 14:51:13 2010 +0000 @@ -345,6 +345,7 @@ DEFUN ("list-length", Flist_length, 1, 1, 0, /* Return the length of LIST. Return nil if LIST is circular. +Error if LIST is dotted. */ (list)) { @@ -359,6 +360,11 @@ tortoise = XCDR (tortoise); } + if (!LISTP (hare)) + { + signal_malformed_list_error (list); + } + return EQ (hare, tortoise) && len != 0 ? Qnil : make_int (len); }
--- a/tests/ChangeLog Tue Nov 02 20:19:39 2010 +0100 +++ b/tests/ChangeLog Sat Nov 06 14:51:13 2010 +0000 @@ -1,3 +1,8 @@ +2010-11-06 Aidan Kehoe <kehoea@parhasard.net> + + * automated/lisp-tests.el (malformed-list): Check that #'mapcar, + #'map and #'list-length throw this error when appropriate. + 2010-10-25 Aidan Kehoe <kehoea@parhasard.net> * automated/lisp-tests.el:
--- a/tests/automated/lisp-tests.el Tue Nov 02 20:19:39 2010 +0100 +++ b/tests/automated/lisp-tests.el Sat Nov 06 14:51:13 2010 +0000 @@ -1040,6 +1040,12 @@ 1) "checking multiple values are correctly discarded in mapcar") +(let ((malformed-list '(1 2 3 4 hi there . tail))) + (Check-Error malformed-list (mapcar #'identity malformed-list)) + (Check-Error malformed-list (map nil #'eq [1 2 3 4] + malformed-list)) + (Check-Error malformed-list (list-length malformed-list))) + ;;----------------------------------------------------- ;; Test vector functions ;;-----------------------------------------------------