MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / setfield

Function setfield

3rd/lua-5.4.3/src/loslib.c:209–216  ·  view source on GitHub ↗

** About the overflow check: an overflow cannot occur when time ** is represented by a lua_Integer, because either lua_Integer is ** large enough to represent all int fields or it is not large enough ** to represent a time that cause a field to overflow. However, if ** times are represented as doubles and lua_Integer is int, then the ** time 0x1.e1853b0d184f6p+55 would cause an overflow when addi

Source from the content-addressed store, hash-verified

207** to compute the year.
208*/
209static void setfield (lua_State *L, const char *key, int value, int delta) {
210 #if (defined(LUA_NUMTIME) && LUA_MAXINTEGER <= INT_MAX)
211 if (l_unlikely(value > LUA_MAXINTEGER - delta))
212 luaL_error(L, "field '%s' is out-of-bound", key);
213 #endif
214 lua_pushinteger(L, (lua_Integer)value + delta);
215 lua_setfield(L, -2, key);
216}
217
218
219static void setboolfield (lua_State *L, const char *key, int value) {

Callers 1

setallfieldsFunction · 0.85

Calls 3

luaL_errorFunction · 0.85
lua_pushintegerFunction · 0.85
lua_setfieldFunction · 0.85

Tested by

no test coverage detected