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

Function getfield

lib/lua/src/loslib.c:253–271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

os_timeFunction · 0.85

Calls 3

lua_getfieldFunction · 0.85
lua_tointegerxFunction · 0.85
luaL_errorFunction · 0.85

Tested by

no test coverage detected