** Convert a number object to a string */
| 369 | ** Convert a number object to a string |
| 370 | */ |
| 371 | void luaO_tostring (lua_State *L, StkId obj) { |
| 372 | char buff[MAXNUMBER2STR]; |
| 373 | size_t len; |
| 374 | lua_assert(ttisnumber(obj)); |
| 375 | if (ttisinteger(obj)) |
| 376 | len = lua_integer2str(buff, sizeof(buff), ivalue(obj)); |
| 377 | else { |
| 378 | len = lua_number2str(buff, sizeof(buff), fltvalue(obj)); |
| 379 | #if !defined(LUA_COMPAT_FLOATSTRING) |
| 380 | if (buff[strspn(buff, "-0123456789")] == '\0') { /* looks like an int? */ |
| 381 | buff[len++] = lua_getlocaledecpoint(); |
| 382 | buff[len++] = '0'; /* adds '.0' to result */ |
| 383 | } |
| 384 | #endif |
| 385 | } |
| 386 | setsvalue2s(L, obj, luaS_newlstr(L, buff, len)); |
| 387 | } |
| 388 | |
| 389 | |
| 390 | static void pushstr (lua_State *L, const char *str, size_t l) { |
no test coverage detected