util-src/ringbuffer.c
changeset 10925 6eb5d2bb11af
parent 10905 5e33926f4b43
child 10957 c3b3ac63f4c3
--- a/util-src/ringbuffer.c	Sun Jun 07 02:14:55 2020 +0200
+++ b/util-src/ringbuffer.c	Sun Jun 07 02:25:56 2020 +0200
@@ -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 @@
 	int peek = lua_toboolean(L, 3);
 
 	if(r > b->blen) {
-		lua_pushnil(L);
+		luaL_pushfail(L);
 		return 1;
 	}
 
@@ -204,7 +208,7 @@
 
 	/* Does `l` bytes fit? */
 	if((l + b->blen) > b->alen) {
-		lua_pushnil(L);
+		luaL_pushfail(L);
 		return 1;
 	}