From 2e068044c6821118bd864d310b0d87bfa3f6ebfd Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Tue, 27 Oct 2015 23:54:08 +0100 Subject: [PATCH] Fixes #3003: Lua io.write() did not support numbers --- radio/src/thirdparty/Lua/src/liolib.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/radio/src/thirdparty/Lua/src/liolib.c b/radio/src/thirdparty/Lua/src/liolib.c index 16e2fb9d3..d5476d298 100644 --- a/radio/src/thirdparty/Lua/src/liolib.c +++ b/radio/src/thirdparty/Lua/src/liolib.c @@ -19,6 +19,7 @@ #include #include #include +#include #define liolib_c @@ -183,14 +184,10 @@ static LStream *newprefile (lua_State *L) { #if !defined(USE_FATFS) static int aux_close (lua_State *L) { -#if !defined(USE_FATFS) LStream *p = tolstream(L); lua_CFunction cf = p->closef; p->closef = NULL; /* mark stream as closed */ return (*cf)(L); /* close it */ -#else - return 0; -#endif } #endif @@ -559,8 +556,9 @@ static int g_write (lua_State *L, FILE *f, int arg) { for (; nargs--; arg++) { if (lua_type(L, arg) == LUA_TNUMBER) { /* optimization: could be done exactly as for strings */ - status = status && - f_printf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0; + char s[LUAI_MAXNUMBER2STR]; + sprintf(s, LUA_NUMBER_FMT, lua_tonumber(L, arg)); + status = status && f_puts(s, f) > 0; } else { size_t l;