MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / luaO_tostring

Function luaO_tostring

src/Chain/libraries/glua/lobject.cpp:329–345  ·  view source on GitHub ↗

** Convert a number object to a string */

Source from the content-addressed store, hash-verified

327** Convert a number object to a string
328*/
329void luaO_tostring(lua_State *L, StkId obj) {
330 char buff[MAXNUMBER2STR];
331 size_t len;
332 lua_assert(ttisnumber(obj));
333 if (ttisinteger(obj))
334 len = lua_integer2str(buff, sizeof(buff), ivalue(obj));
335 else {
336 len = lua_number2str(buff, sizeof(buff), fltvalue(obj));
337#if !defined(LUA_COMPAT_FLOATSTRING)
338 if (buff[strspn(buff, "-0123456789")] == '\0') { /* looks like an int? */
339 buff[len++] = lua_getlocaledecpoint();
340 buff[len++] = '0'; /* adds '.0' to result */
341 }
342#endif
343 }
344 setsvalue2s(L, obj, luaS_newlstr(L, buff, len));
345}
346
347
348static void pushstr(lua_State *L, const char *str, size_t l) {

Callers 2

luaO_pushvfstringFunction · 0.85
lua_tolstringFunction · 0.85

Calls 1

luaS_newlstrFunction · 0.85

Tested by

no test coverage detected