From Lua 5.2: Return file object for io.write() and file:write().

Needs -DLUAJIT_ENABLE_LUA52COMPAT.
This commit is contained in:
Mike Pall
2012-09-28 17:54:18 +02:00
parent 26841296ab
commit 7a6bb9a208
2 changed files with 11 additions and 4 deletions

View File

@@ -244,6 +244,12 @@ static int io_file_write(lua_State *L, FILE *fp, int start)
lj_err_argt(L, (int)(tv - L->base) + 1, LUA_TSTRING);
}
}
if (LJ_52 && status) {
L->top = L->base+1;
if (start == 0)
setudataV(L, L->base, IOSTDF_UD(L, GCROOT_IO_OUTPUT));
return 1;
}
return luaL_fileresult(L, status, NULL);
}