#include <signal.h>
+#include <ctype.h>
#include "config.h"
#include "lisp.h"
{
if (XTYPE (value) == Lisp_String &&
(EQ (predicate, Qintegerp) || EQ (predicate, Qinteger_or_marker_p)))
- return Fstring_to_int (value, Qt);
+ return Fstring_to_number (value);
if (XTYPE (value) == Lisp_Int && EQ (predicate, Qstringp))
return Fint_to_string (value);
}
return Qnil;
}
-DEFUN ("compiled-function-p", Fcompiled_function_p, Scompiled_function_p,
- 1, 1, 0, "T if OBJECT is a compiled function object.")
+DEFUN ("byte-code-function-p", Fbyte_code_function_p, Sbyte_code_function_p,
+ 1, 1, 0, "T if OBJECT is a byte-compiled function object.")
(obj)
Lisp_Object obj;
{
(obj)
Lisp_Object obj;
{
- if (0
-#ifdef LISP_FLOAT_TYPE
- || XTYPE (obj) == Lisp_Float
-#endif
- || XTYPE (obj) == Lisp_Int)
+ if (NUMBERP (obj))
return Qt;
- return Qnil;
+ else
+ return Qnil;
}
DEFUN ("number-or-marker-p", Fnumber_or_marker_p,
(obj)
Lisp_Object obj;
{
- if (XTYPE (obj) == Lisp_Int
-#ifdef LISP_FLOAT_TYPE
- || XTYPE (obj) == Lisp_Float
-#endif
+ if (NUMBERP (obj)
|| XTYPE (obj) == Lisp_Marker)
return Qt;
return Qnil;
This is like Findirect_function, except that it doesn't signal an
error if the chain ends up unbound. */
Lisp_Object
-indirect_function (object, error)
+indirect_function (object)
register Lisp_Object object;
{
Lisp_Object tortise, hare;
if (floatp ? f1 >= f2 : XINT (num1) >= XINT (num2))
return Qt;
return Qnil;
+
+ default:
+ abort ();
}
}
}
\f
DEFUN ("int-to-string", Fint_to_string, Sint_to_string, 1, 1, 0,
- "Convert INT to a string by printing it in decimal.\n\
-Uses a minus sign if negative.")
+ "Convert NUM to a string by printing it in decimal.\n\
+Uses a minus sign if negative.\n\
+NUM may be an integer or a floating point number.")
(num)
Lisp_Object num;
{
return build_string (buffer);
}
-DEFUN ("string-to-int", Fstring_to_int, Sstring_to_int, 1, 1, 0,
- "Convert STRING to an integer by parsing it as a decimal number.")
+DEFUN ("string-to-number", Fstring_to_number, Sstring_to_number, 1, 1, 0,
+ "Convert STRING to a number by parsing it as a decimal number.\n\
+This parses both integers and floating point numbers.")
(str)
register Lisp_Object str;
{
+ char *p;
+
CHECK_STRING (str, 0);
+ p = XSTRING (str)->data;
+
+ /* Skip any whitespace at the front of the number. Some versions of
+ atoi do this anyway, so we might as well make Emacs lisp consistent. */
+ while (isspace (*p))
+ p++;
+
#ifdef LISP_FLOAT_TYPE
- if (isfloat_string (XSTRING (str)->data))
- return make_float (atof (XSTRING (str)->data));
+ if (isfloat_string (p))
+ return make_float (atof (p));
#endif /* LISP_FLOAT_TYPE */
- return make_number (atoi (XSTRING (str)->data));
+ return make_number (atoi (p));
}
\f
enum arithop
defsubr (&Sbufferp);
defsubr (&Smarkerp);
defsubr (&Ssubrp);
- defsubr (&Scompiled_function_p);
+ defsubr (&Sbyte_code_function_p);
defsubr (&Schar_or_string_p);
defsubr (&Scar);
defsubr (&Scdr);
defsubr (&Saref);
defsubr (&Saset);
defsubr (&Sint_to_string);
- defsubr (&Sstring_to_int);
+ defsubr (&Sstring_to_number);
defsubr (&Seqlsign);
defsubr (&Slss);
defsubr (&Sgtr);