diff options
author | Aki <please@ignore.pl> | 2021-02-24 22:38:08 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2021-02-24 22:45:04 +0100 |
commit | 1aceae67491cd871c1be063ba7f02bf6db85a1fa (patch) | |
tree | da34fd8f841cfe1be86e5f5dc9bf239630ae614d | |
parent | 140c90ec899298821c35665abc1073fa9d9446d7 (diff) | |
download | plop-1aceae67491cd871c1be063ba7f02bf6db85a1fa.zip plop-1aceae67491cd871c1be063ba7f02bf6db85a1fa.tar.gz plop-1aceae67491cd871c1be063ba7f02bf6db85a1fa.tar.bz2 |
Added arguments to stream's read
-rw-r--r-- | stream.c | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -74,7 +74,14 @@ int stream_gc(lua_State * L) /// \return Number of the results pushed to the stack int stream_read(lua_State * L) { - struct stream * s = lua_touserdata(L, -1); + int n = lua_gettop(L); + if (2 > n) + { + lua_pushliteral(L, "At least two arguments expected"); + return lua_error(L); + } + + struct stream * s = lua_touserdata(L, 1); if (NULL == s) { @@ -129,7 +136,11 @@ int stream_readk(lua_State * L, int status, lua_KContext ctx) s->in.offset = 0; lua_pushstring(L, s->in.data); - lua_remove(L, -2); + + for (int n = -lua_gettop(L); n < -1; ++n) + { + lua_remove(L, n); + } return 1; } |