diff src/fns.c @ 274:ca9a9ec9c1c1 r21-0b35

Import from CVS: tag r21-0b35
author cvs
date Mon, 13 Aug 2007 10:29:42 +0200
parents c5d627a313b1
children 6330739388db
line wrap: on
line diff
--- a/src/fns.c	Mon Aug 13 10:28:54 2007 +0200
+++ b/src/fns.c	Mon Aug 13 10:29:42 2007 +0200
@@ -964,16 +964,21 @@
        (n, list))
 {
   REGISTER int i;
+  REGISTER Lisp_Object tail = list;
   CHECK_NATNUM (n);
   for (i = XINT (n); i; i--)
     {
-      if (NILP (list))
-	return list;
-      CHECK_CONS (list);
-      list = XCDR (list);
-      QUIT;
+      if (CONSP (tail))
+	tail = XCDR (tail);
+      else if (NILP (tail))
+	return Qnil;
+      else
+	{
+	  tail = wrong_type_argument (Qlistp, tail);
+	  i++;
+	}
     }
-  return list;
+  return tail;
 }
 
 DEFUN ("nth", Fnth, 2, 2, 0, /*
@@ -1006,7 +1011,7 @@
 	/* This is The Way It Has Always Been. */
 	return Qnil;
 #else
-        /* This is The Way Mly Says It Should Be. */
+        /* This is The Way Mly and Cltl2 say It Should Be. */
         args_out_of_range (sequence, n);
 #endif
     }