mirror of https://github.com/rusefi/lua.git
added a compat option (although it will be off by default) to
the addition of '.0' to float->string conversions
This commit is contained in:
parent
e58ef8d0bb
commit
f8daddba50
4
lvm.c
4
lvm.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lvm.c,v 2.208 2014/05/12 21:22:05 roberto Exp roberto $
|
** $Id: lvm.c,v 2.209 2014/05/12 21:44:17 roberto Exp roberto $
|
||||||
** Lua virtual machine
|
** Lua virtual machine
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -140,10 +140,12 @@ int luaV_tostring (lua_State *L, StkId obj) {
|
||||||
len = lua_integer2str(buff, ivalue(obj));
|
len = lua_integer2str(buff, ivalue(obj));
|
||||||
else {
|
else {
|
||||||
len = lua_number2str(buff, fltvalue(obj));
|
len = lua_number2str(buff, fltvalue(obj));
|
||||||
|
#if !defined(LUA_COMPAT_FLOATSTRING)
|
||||||
if (buff[strspn(buff, "-0123456789")] == '\0') { /* looks like an int? */
|
if (buff[strspn(buff, "-0123456789")] == '\0') { /* looks like an int? */
|
||||||
buff[len++] = '.';
|
buff[len++] = '.';
|
||||||
buff[len++] = '0'; /* adds '.0' to result */
|
buff[len++] = '0'; /* adds '.0' to result */
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
setsvalue2s(L, obj, luaS_newlstr(L, buff, len));
|
setsvalue2s(L, obj, luaS_newlstr(L, buff, len));
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in New Issue