Add 2010 to copyright years.
[bpt/emacs.git] / src / data.c
index fc50658..e405ca6 100644 (file)
@@ -1,6 +1,6 @@
 /* Primitive operations on Lisp data types for GNU Emacs Lisp interpreter.
    Copyright (C) 1985, 1986, 1988, 1993, 1994, 1995, 1997, 1998, 1999, 2000,
-                 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+                 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
                  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -108,10 +108,12 @@ Lisp_Object
 wrong_type_argument (predicate, value)
      register Lisp_Object predicate, value;
 {
-  /* If VALUE is not even a valid Lisp object, abort here
-     where we can get a backtrace showing where it came from.  */
-  if ((unsigned int) XTYPE (value) >= Lisp_Type_Limit)
-    abort ();
+  /* If VALUE is not even a valid Lisp object, we'd want to abort here
+     where we can get a backtrace showing where it came from.  We used
+     to try and do that by checking the tagbits, but nowadays all
+     tagbits are potentially valid.  */
+  /* if ((unsigned int) XTYPE (value) >= Lisp_Type_Limit)
+   *   abort (); */
 
   xsignal2 (Qwrong_type_argument, predicate, value);
 }
@@ -184,7 +186,7 @@ for example, (type-of 1) returns `integer'.  */)
 {
   switch (XTYPE (object))
     {
-    case Lisp_Int:
+    case_Lisp_Int:
       return Qinteger;
 
     case Lisp_Symbol:
@@ -975,8 +977,10 @@ store_symval_forwarding (symbol, valcontents, newval, buf)
            int offset = XBUFFER_OBJFWD (valcontents)->offset;
            Lisp_Object type = XBUFFER_OBJFWD (valcontents)->slottype;
 
-           if (! NILP (type) && ! NILP (newval)
-               && XTYPE (newval) != XINT (type))
+           if (!(NILP (type) || NILP (newval)
+                 || (XINT (type) == LISP_INT_TAG
+                     ? INTEGERP (newval)
+                     : XTYPE (newval) == XINT (type))))
              buffer_slot_type_mismatch (newval, XINT (type));
 
            if (buf == NULL)
@@ -1766,7 +1770,7 @@ BUFFER defaults to the current buffer.  */)
   CHECK_SYMBOL (variable);
   sym = indirect_variable (XSYMBOL (variable));
   XSETSYMBOL (variable, sym);
-  
+
   valcontents = sym->value;
   if (BUFFER_LOCAL_VALUEP (valcontents))
     {
@@ -2003,8 +2007,7 @@ or a byte-code object.  IDX starts at 0.  */)
        return make_number ((unsigned char) SREF (array, idxval));
       idxval_byte = string_char_to_byte (array, idxval);
 
-      c = STRING_CHAR (SDATA (array) + idxval_byte,
-                      SBYTES (array) - idxval_byte);
+      c = STRING_CHAR (SDATA (array) + idxval_byte);
       return make_number (c);
     }
   else if (BOOL_VECTOR_P (array))
@@ -2350,11 +2353,11 @@ digit_to_number (character, base)
 DEFUN ("string-to-number", Fstring_to_number, Sstring_to_number, 1, 2, 0,
        doc: /* Parse STRING as a decimal number and return the number.
 This parses both integers and floating point numbers.
-It ignores leading spaces and tabs.
+It ignores leading spaces and tabs, and all trailing chars.
 
 If BASE, interpret STRING as a number in that base.  If BASE isn't
 present, base 10 is used.  BASE must be between 2 and 16 (inclusive).
-If the base used is not 10, floating point is not recognized.  */)
+If the base used is not 10, STRING is always parsed as integer.  */)
      (string, base)
      register Lisp_Object string, base;
 {
@@ -2389,7 +2392,7 @@ If the base used is not 10, floating point is not recognized.  */)
   else if (*p == '+')
     p++;
 
-  if (isfloat_string (p) && b == 10)
+  if (isfloat_string (p, 1) && b == 10)
     val = make_float (sign * atof (p));
   else
     {