Permalink
Browse files

io: fix empty string skipping code

  • Loading branch information...
1 parent 1074e60 commit 0b0c4006ace26c3d26a666cb012c25e844ed380c @esmil committed Feb 5, 2013
Showing with 4 additions and 4 deletions.
  1. +2 −2 lem/io/file.c
  2. +2 −2 lem/io/stream.c
View
@@ -258,7 +258,7 @@ file_write(lua_State *T)
idx = 1;
do {
str = luaL_checklstring(T, ++idx, &len);
- } while (len == 0 && idx <= top);
+ } while (len == 0 && idx < top);
for (i = idx+1; i <= top; i++)
(void)luaL_checkstring(T, i);
@@ -267,7 +267,7 @@ file_write(lua_State *T)
return io_closed(T);
if (f->a.T != NULL)
return io_busy(T);
- if (idx > top) {
+ if (len == 0) {
lua_pushboolean(T, 1);
return 1;
}
View
@@ -275,7 +275,7 @@ stream_write(lua_State *T)
idx = 1;
do {
out = luaL_checklstring(T, ++idx, &out_len);
- } while (out_len == 0 && idx <= top);
+ } while (out_len == 0 && idx < top);
for (i = idx+1; i <= top; i++)
(void)luaL_checkstring(T, i);
@@ -284,7 +284,7 @@ stream_write(lua_State *T)
return io_closed(T);
if (s->w.data != NULL)
return io_busy(T);
- if (idx > top) {
+ if (out_len == 0) {
lua_pushboolean(T, 1);
return 1;
}

0 comments on commit 0b0c400

Please sign in to comment.