MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / tonum

Function tonum

extlibs/lua/src/lstrlib.c:263–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261#else /* }{ */
262
263static int tonum (lua_State *L, int arg) {
264 if (lua_type(L, arg) == LUA_TNUMBER) { /* already a number? */
265 lua_pushvalue(L, arg);
266 return 1;
267 }
268 else { /* check whether it is a numerical string */
269 size_t len;
270 const char *s = lua_tolstring(L, arg, &len);
271 return (s != NULL && lua_stringtonumber(L, s) == len + 1);
272 }
273}
274
275
276static void trymt (lua_State *L, const char *mtname) {

Callers 1

arithFunction · 0.85

Calls 4

lua_typeFunction · 0.85
lua_pushvalueFunction · 0.85
lua_tolstringFunction · 0.85
lua_stringtonumberFunction · 0.70

Tested by

no test coverage detected