comparison src/fns.c @ 5355:70b15ac66ee5

Correct a bug with circularity checking in #'mapcar*, #'map, etc. src/ChangeLog addition: 2011-02-10 Aidan Kehoe <kehoea@parhasard.net> * fns.c (shortest_length_among_sequences): This was buggy, it always errored if the last argument was circular, even if other arguments were non-circular. Correct that. tests/ChangeLog addition: 2011-02-10 Aidan Kehoe <kehoea@parhasard.net> * automated/lisp-tests.el: * automated/lisp-tests.el (mapcar*): If multiple SEQUENCE arguments are passed to #'mapcar*, and the last one is circular while the others aren't, make sure that #'mapcar* doesn't error.
author Aidan Kehoe <kehoea@parhasard.net>
date Thu, 10 Feb 2011 08:46:10 +0000
parents 94bbd4792049
children f5a5501814f5 00e79bbbe48f
comparison
equal deleted inserted replaced
5354:22c4e67a2e69 5355:70b15ac66ee5
7143 the length of the shortest sequence. Error if all are circular, or if any 7143 the length of the shortest sequence. Error if all are circular, or if any
7144 one of them is not a sequence. */ 7144 one of them is not a sequence. */
7145 static Elemcount 7145 static Elemcount
7146 shortest_length_among_sequences (int nsequences, Lisp_Object *sequences) 7146 shortest_length_among_sequences (int nsequences, Lisp_Object *sequences)
7147 { 7147 {
7148 Elemcount len = EMACS_INT_MAX; 7148 Elemcount len = 1 + EMACS_INT_MAX;
7149 Lisp_Object length = Qnil; 7149 Lisp_Object length = Qnil;
7150 int i; 7150 int i;
7151 7151
7152 for (i = 0; i < nsequences; ++i) 7152 for (i = 0; i < nsequences; ++i)
7153 { 7153 {
7165 length = Flength (sequences[i]); 7165 length = Flength (sequences[i]);
7166 len = min (len, XINT (length)); 7166 len = min (len, XINT (length));
7167 } 7167 }
7168 } 7168 }
7169 7169
7170 if (NILP (length)) 7170 if (len == 1 + EMACS_INT_MAX)
7171 { 7171 {
7172 signal_circular_list_error (sequences[0]); 7172 signal_circular_list_error (sequences[0]);
7173 } 7173 }
7174 7174
7175 return len; 7175 return len;