From 625ec0a93f194fa152b0cf0b94f60afdee224df9 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 7 Jun 2020 02:25:56 +0200 Subject: util-src: Use the luaL_pushfail API added in Lua 5.4 to highlight all failure conditions Actually just an alias of pushnil, but it does make it more obvious where the failure conditions are, which is good for readability. --- util-src/ringbuffer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'util-src/ringbuffer.c') diff --git a/util-src/ringbuffer.c b/util-src/ringbuffer.c index 07e1096f..007aa2ec 100644 --- a/util-src/ringbuffer.c +++ b/util-src/ringbuffer.c @@ -6,6 +6,10 @@ #include #include +#if (LUA_VERSION_NUM < 504) +#define luaL_pushfail lua_pushnil +#endif + typedef struct { size_t rpos; /* read position */ size_t wpos; /* write position */ @@ -152,7 +156,7 @@ static int rb_read(lua_State *L) { int peek = lua_toboolean(L, 3); if(r > b->blen) { - lua_pushnil(L); + luaL_pushfail(L); return 1; } @@ -204,7 +208,7 @@ static int rb_write(lua_State *L) { /* Does `l` bytes fit? */ if((l + b->blen) > b->alen) { - lua_pushnil(L); + luaL_pushfail(L); return 1; } -- cgit v1.2.3