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