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

Function getfield

third-party/lua-5.5.0/src/loslib.c:254–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

252
253
254static int getfield (lua_State *L, const char *key, int d, int delta) {
255 int isnum;
256 int t = lua_getfield(L, -1, key); /* get field and its type */
257 lua_Integer res = lua_tointegerx(L, -1, &isnum);
258 if (!isnum) { /* field is not an integer? */
259 if (l_unlikely(t != LUA_TNIL)) /* some other value? */
260 return luaL_error(L, "field '%s' is not an integer", key);
261 else if (l_unlikely(d < 0)) /* absent field; no default? */
262 return luaL_error(L, "field '%s' missing in date table", key);
263 res = d;
264 }
265 else {
266 if (!(res >= 0 ? res - delta <= INT_MAX : INT_MIN + delta <= res))
267 return luaL_error(L, "field '%s' is out-of-bound", key);
268 res -= delta;
269 }
270 lua_pop(L, 1);
271 return (int)res;
272}
273
274
275static const char *checkoption (lua_State *L, const char *conv,

Callers 1

os_timeFunction · 0.70

Calls 3

lua_getfieldFunction · 0.70
lua_tointegerxFunction · 0.70
luaL_errorFunction · 0.70

Tested by

no test coverage detected