diff options
author | Kim Alvefur <zash@zash.se> | 2020-06-07 02:25:56 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2020-06-07 02:25:56 +0200 |
commit | 625ec0a93f194fa152b0cf0b94f60afdee224df9 (patch) | |
tree | f547a1c5e6015d76b345f21ea6707f48bc716b26 /util-src/ringbuffer.c | |
parent | b50db460865f3f0a1b1dbad90ee3bc5fbcec3a8f (diff) | |
download | prosody-625ec0a93f194fa152b0cf0b94f60afdee224df9.tar.gz prosody-625ec0a93f194fa152b0cf0b94f60afdee224df9.zip |
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.
Diffstat (limited to 'util-src/ringbuffer.c')
-rw-r--r-- | util-src/ringbuffer.c | 8 |
1 files changed, 6 insertions, 2 deletions
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 <lua.h> #include <lauxlib.h> +#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; } |