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