mirror of https://github.com/rusefi/lua.git
correct support for changing real to double (optional)
This commit is contained in:
parent
caa987faad
commit
a7793468aa
4
lex.c
4
lex.c
|
@ -1,4 +1,4 @@
|
|||
char *rcs_lex = "$Id: lex.c,v 3.7 1997/07/29 13:33:15 roberto Exp roberto $";
|
||||
char *rcs_lex = "$Id: lex.c,v 3.8 1997/07/30 22:00:50 roberto Exp roberto $";
|
||||
|
||||
|
||||
#include <ctype.h>
|
||||
|
@ -432,7 +432,7 @@ int luaY_lex (void)
|
|||
ea*=ea;
|
||||
}
|
||||
}
|
||||
luaY_lval.vFloat = a;
|
||||
luaY_lval.vReal = a;
|
||||
save(0);
|
||||
return NUMBER;
|
||||
}
|
||||
|
|
27
opcode.c
27
opcode.c
|
@ -3,7 +3,7 @@
|
|||
** TecCGraf - PUC-Rio
|
||||
*/
|
||||
|
||||
char *rcs_opcode="$Id: opcode.c,v 4.19 1997/07/29 21:11:10 roberto Exp roberto $";
|
||||
char *rcs_opcode="$Id: opcode.c,v 4.20 1997/07/30 22:00:50 roberto Exp roberto $";
|
||||
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
|
@ -141,18 +141,17 @@ static char *lua_strconc (char *l, char *r)
|
|||
*/
|
||||
static int lua_tonumber (TObject *obj)
|
||||
{
|
||||
float t;
|
||||
char c;
|
||||
if (ttype(obj) != LUA_T_STRING)
|
||||
return 1;
|
||||
else if (sscanf(svalue(obj), "%f %c",&t, &c) == 1)
|
||||
{
|
||||
nvalue(obj) = t;
|
||||
ttype(obj) = LUA_T_NUMBER;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 2;
|
||||
double t;
|
||||
char c;
|
||||
if (ttype(obj) != LUA_T_STRING)
|
||||
return 1;
|
||||
else if (sscanf(svalue(obj), "%lf %c",&t, &c) == 1) {
|
||||
nvalue(obj) = (real)t;
|
||||
ttype(obj) = LUA_T_NUMBER;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
|
@ -171,7 +170,7 @@ static int lua_tostring (TObject *obj)
|
|||
if ((real)(-MAX_INT) <= f && f <= (real)MAX_INT && (real)(i=(int)f) == f)
|
||||
sprintf (s, "%d", i);
|
||||
else
|
||||
sprintf (s, "%g", nvalue(obj));
|
||||
sprintf (s, "%g", (double)nvalue(obj));
|
||||
tsvalue(obj) = luaI_createstring(s);
|
||||
ttype(obj) = LUA_T_STRING;
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue