aboutsummaryrefslogtreecommitdiff
path: root/liolib.c
diff options
context:
space:
mode:
Diffstat (limited to 'liolib.c')
-rw-r--r--liolib.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/liolib.c b/liolib.c
index 82f444b0..c5075f3e 100644
--- a/liolib.c
+++ b/liolib.c
@@ -570,6 +570,7 @@ static int g_read (lua_State *L, FILE *f, int first) {
570 int nargs = lua_gettop(L) - 1; 570 int nargs = lua_gettop(L) - 1;
571 int n, success; 571 int n, success;
572 clearerr(f); 572 clearerr(f);
573 errno = 0;
573 if (nargs == 0) { /* no arguments? */ 574 if (nargs == 0) { /* no arguments? */
574 success = read_line(L, f, 1); 575 success = read_line(L, f, 1);
575 n = first + 1; /* to return 1 result */ 576 n = first + 1; /* to return 1 result */
@@ -606,10 +607,8 @@ static int g_read (lua_State *L, FILE *f, int first) {
606 } 607 }
607 } 608 }
608 } 609 }
609 if (ferror(f)) { 610 if (ferror(f))
610 errno = 0; /* no relevant errno here */
611 return luaL_fileresult(L, 0, NULL); 611 return luaL_fileresult(L, 0, NULL);
612 }
613 if (!success) { 612 if (!success) {
614 lua_pop(L, 1); /* remove last result */ 613 lua_pop(L, 1); /* remove last result */
615 luaL_pushfail(L); /* push nil instead */ 614 luaL_pushfail(L); /* push nil instead */
@@ -665,6 +664,7 @@ static int io_readline (lua_State *L) {
665static int g_write (lua_State *L, FILE *f, int arg) { 664static int g_write (lua_State *L, FILE *f, int arg) {
666 int nargs = lua_gettop(L) - arg; 665 int nargs = lua_gettop(L) - arg;
667 int status = 1; 666 int status = 1;
667 errno = 0;
668 for (; nargs--; arg++) { 668 for (; nargs--; arg++) {
669 if (lua_type(L, arg) == LUA_TNUMBER) { 669 if (lua_type(L, arg) == LUA_TNUMBER) {
670 /* optimization: could be done exactly as for strings */ 670 /* optimization: could be done exactly as for strings */
@@ -683,10 +683,8 @@ static int g_write (lua_State *L, FILE *f, int arg) {
683 } 683 }
684 if (l_likely(status)) 684 if (l_likely(status))
685 return 1; /* file handle already on stack top */ 685 return 1; /* file handle already on stack top */
686 else { 686 else
687 errno = 0; /* no relevant errno here */
688 return luaL_fileresult(L, status, NULL); 687 return luaL_fileresult(L, status, NULL);
689 }
690} 688}
691 689
692 690