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

Function getfield

third-party/lua-5.3.5/src/loslib.c:239–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237#endif
238
239static int getfield (lua_State *L, const char *key, int d, int delta) {
240 int isnum;
241 int t = lua_getfield(L, -1, key); /* get field and its type */
242 lua_Integer res = lua_tointegerx(L, -1, &isnum);
243 if (!isnum) { /* field is not an integer? */
244 if (t != LUA_TNIL) /* some other value? */
245 return luaL_error(L, "field '%s' is not an integer", key);
246 else if (d < 0) /* absent field; no default? */
247 return luaL_error(L, "field '%s' missing in date table", key);
248 res = d;
249 }
250 else {
251 if (!(-L_MAXDATEFIELD <= res && res <= L_MAXDATEFIELD))
252 return luaL_error(L, "field '%s' is out-of-bound", key);
253 res -= delta;
254 }
255 lua_pop(L, 1);
256 return (int)res;
257}
258
259
260static 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