MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / tonum

Function tonum

lib/lua/src/lstrlib.c:264–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262#else /* }{ */
263
264static int tonum (lua_State *L, int arg) {
265 if (lua_type(L, arg) == LUA_TNUMBER) { /* already a number? */
266 lua_pushvalue(L, arg);
267 return 1;
268 }
269 else { /* check whether it is a numerical string */
270 size_t len;
271 const char *s = lua_tolstring(L, arg, &len);
272 return (s != NULL && lua_stringtonumber(L, s) == len + 1);
273 }
274}
275
276
277static 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.85

Tested by

no test coverage detected