diff options
-rw-r--r-- | liolib.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: liolib.c,v 2.112 2013/04/11 18:34:06 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 2.113 2013/05/14 15:57:43 roberto Exp roberto $ |
3 | ** Standard I/O (and system) library | 3 | ** Standard I/O (and system) library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -533,8 +533,10 @@ static int g_write (lua_State *L, FILE *f, int arg) { | |||
533 | for (; nargs--; arg++) { | 533 | for (; nargs--; arg++) { |
534 | if (lua_type(L, arg) == LUA_TNUMBER) { | 534 | if (lua_type(L, arg) == LUA_TNUMBER) { |
535 | /* optimization: could be done exactly as for strings */ | 535 | /* optimization: could be done exactly as for strings */ |
536 | status = status && | 536 | int len = lua_isinteger(L, arg) |
537 | fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0; | 537 | ? fprintf(f, LUA_INTEGER_FMT, lua_tointeger(L, arg)) |
538 | : fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)); | ||
539 | status = status && (len > 0); | ||
538 | } | 540 | } |
539 | else { | 541 | else { |
540 | size_t l; | 542 | size_t l; |