APPROVE COMMIT
NOTE: This patch has been committed.
# HG changeset patch
# User Aidan Kehoe <kehoea(a)parhasard.net>
# Date 1289055073 0
# Node ID 28651c24b3f8db171de88a939777895c737612e8
# Parent 99006e0b3a84c438445d8b177ccc0060663d3700
Error in #'list-length if LIST is dotted; check for this error with #'mapcar
src/ChangeLog addition:
2010-11-06 Aidan Kehoe <kehoea(a)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(a)parhasard.net>
* automated/lisp-tests.el (malformed-list): Check that #'mapcar,
#'map and #'list-length throw this error when appropriate.
diff -r 99006e0b3a84 -r 28651c24b3f8 src/ChangeLog
--- 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(a)parhasard.net>
+
+ * fns.c (Flist_length): Error if LIST is dotted in this function;
+ document this behaviour.
+
2010-10-25 Aidan Kehoe <kehoea(a)parhasard.net>
* specifier.c (specifier_instance_from_inst_list):
diff -r 99006e0b3a84 -r 28651c24b3f8 src/fns.c
--- 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);
}
diff -r 99006e0b3a84 -r 28651c24b3f8 tests/ChangeLog
--- 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(a)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(a)parhasard.net>
* automated/lisp-tests.el:
diff -r 99006e0b3a84 -r 28651c24b3f8 tests/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
;;-----------------------------------------------------
--
“Apart from the nine-banded armadillo, man is the only natural host of
Mycobacterium leprae, although it can be grown in the footpads of mice.”
-- Kumar & Clark, Clinical Medicine, summarising improbable leprosy research
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches