diff options
author | Li Jin <dragon-fly@qq.com> | 2021-03-03 21:31:01 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2021-03-03 21:33:37 +0800 |
commit | 1df786307c1983b8ce693e3916081a8bcd4e95ae (patch) | |
tree | 6c7aeb2198d825877fd3d179c394b7a5c1f06a17 /src/lua/loslib.c | |
parent | 66168b112b707172b9035edf8c1daed469781e06 (diff) | |
download | yuescript-1df786307c1983b8ce693e3916081a8bcd4e95ae.tar.gz yuescript-1df786307c1983b8ce693e3916081a8bcd4e95ae.tar.bz2 yuescript-1df786307c1983b8ce693e3916081a8bcd4e95ae.zip |
add new metatable syntax for issue #41, fix reusing local variable issue, update built-in Lua.
Diffstat (limited to 'src/lua/loslib.c')
-rw-r--r-- | src/lua/loslib.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lua/loslib.c b/src/lua/loslib.c index e65e188..3e20d62 100644 --- a/src/lua/loslib.c +++ b/src/lua/loslib.c | |||
@@ -170,7 +170,7 @@ static int os_tmpname (lua_State *L) { | |||
170 | char buff[LUA_TMPNAMBUFSIZE]; | 170 | char buff[LUA_TMPNAMBUFSIZE]; |
171 | int err; | 171 | int err; |
172 | lua_tmpnam(buff, err); | 172 | lua_tmpnam(buff, err); |
173 | if (err) | 173 | if (l_unlikely(err)) |
174 | return luaL_error(L, "unable to generate a unique filename"); | 174 | return luaL_error(L, "unable to generate a unique filename"); |
175 | lua_pushstring(L, buff); | 175 | lua_pushstring(L, buff); |
176 | return 1; | 176 | return 1; |
@@ -208,7 +208,7 @@ static int os_clock (lua_State *L) { | |||
208 | */ | 208 | */ |
209 | static void setfield (lua_State *L, const char *key, int value, int delta) { | 209 | static void setfield (lua_State *L, const char *key, int value, int delta) { |
210 | #if (defined(LUA_NUMTIME) && LUA_MAXINTEGER <= INT_MAX) | 210 | #if (defined(LUA_NUMTIME) && LUA_MAXINTEGER <= INT_MAX) |
211 | if (value > LUA_MAXINTEGER - delta) | 211 | if (l_unlikely(value > LUA_MAXINTEGER - delta)) |
212 | luaL_error(L, "field '%s' is out-of-bound", key); | 212 | luaL_error(L, "field '%s' is out-of-bound", key); |
213 | #endif | 213 | #endif |
214 | lua_pushinteger(L, (lua_Integer)value + delta); | 214 | lua_pushinteger(L, (lua_Integer)value + delta); |
@@ -253,9 +253,9 @@ static int getfield (lua_State *L, const char *key, int d, int delta) { | |||
253 | int t = lua_getfield(L, -1, key); /* get field and its type */ | 253 | int t = lua_getfield(L, -1, key); /* get field and its type */ |
254 | lua_Integer res = lua_tointegerx(L, -1, &isnum); | 254 | lua_Integer res = lua_tointegerx(L, -1, &isnum); |
255 | if (!isnum) { /* field is not an integer? */ | 255 | if (!isnum) { /* field is not an integer? */ |
256 | if (t != LUA_TNIL) /* some other value? */ | 256 | if (l_unlikely(t != LUA_TNIL)) /* some other value? */ |
257 | return luaL_error(L, "field '%s' is not an integer", key); | 257 | return luaL_error(L, "field '%s' is not an integer", key); |
258 | else if (d < 0) /* absent field; no default? */ | 258 | else if (l_unlikely(d < 0)) /* absent field; no default? */ |
259 | return luaL_error(L, "field '%s' missing in date table", key); | 259 | return luaL_error(L, "field '%s' missing in date table", key); |
260 | res = d; | 260 | res = d; |
261 | } | 261 | } |