# HG changeset patch # User Richard M. Stallman # Date 799642755 0 # Node ID d0eaa6b6dc72dd030d601691d9bfeb97fceae1a0 # Parent 79358a3240fe0ee1bc684c302751dee873f21e2a (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. diff -r 79358a3240fe -r d0eaa6b6dc72 src/data.c --- 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