changeset 11701:d0eaa6b6dc72

(Fnumber_to_string, Fstring_to_number): Handle long EMACS_INT in sprintf and atol. (store_symval_forwarding): Error if value out of range for an integer variable. (Fstring_to_number): Avoid using make_number to return value. Maybe use atol.
author Richard M. Stallman <rms@gnu.org>
date Fri, 05 May 1995 02:59:15 +0000
parents 79358a3240fe
children afad0099d14b
files src/data.c
diffstat 1 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/data.c	Fri May 05 02:56:50 1995 +0000
+++ b/src/data.c	Fri May 05 02:59:15 1995 +0000
@@ -737,6 +737,9 @@
 	case Lisp_Misc_Intfwd:
 	  CHECK_NUMBER (newval, 1);
 	  *XINTFWD (valcontents)->intvar = XINT (newval);
+	  if (*XINTFWD (valcontents)->intvar != XINT (newval))
+	    error ("Value out of range for variable `%s'",
+		   XSYMBOL (sym)->name->data);
 	  break;
 
 	case Lisp_Misc_Boolfwd:
@@ -1664,7 +1667,12 @@
     }
 #endif /* LISP_FLOAT_TYPE */
 
-  sprintf (buffer, "%d", XINT (num));
+  if (sizeof (int) == sizeof (EMACS_INT))
+    sprintf (buffer, "%d", XINT (num));
+  else if (sizeof (long) == sizeof (EMACS_INT))
+    sprintf (buffer, "%ld", XINT (num));
+  else
+    abort ();
   return build_string (buffer);
 }
 
@@ -1675,6 +1683,7 @@
   (str)
      register Lisp_Object str;
 {
+  Lisp_Object value;
   unsigned char *p;
 
   CHECK_STRING (str, 0);
@@ -1691,7 +1700,13 @@
     return make_float (atof (p));
 #endif /* LISP_FLOAT_TYPE */
 
-  return make_number (atoi (p));
+  if (sizeof (int) == sizeof (EMACS_INT))
+    XSETINT (value, atoi (p));
+  else if (sizeof (long) == sizeof (EMACS_INT))
+    XSETINT (value, atol (p));
+  else
+    abort ();
+  return value;
 }
 
 enum arithop