MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / luaO_tostring

Function luaO_tostring

third-party/lua-5.3.5/src/lobject.c:371–387  ·  view source on GitHub ↗

** Convert a number object to a string */

Source from the content-addressed store, hash-verified

369** Convert a number object to a string
370*/
371void 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
390static void pushstr (lua_State *L, const char *str, size_t l) {

Callers 2

luaO_pushvfstringFunction · 0.70
lua_tolstringFunction · 0.70

Calls 1

luaS_newlstrFunction · 0.70

Tested by

no test coverage detected