From 741562e84c2a33e38858ef379b3db95406a75a79 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 14 Oct 2022 18:44:36 +0200 Subject: [PATCH] Cleanup: Use Lua's native setvbuf wrapper instead of reinventing the wheel (#9636) Sidenote for the crazy win32 people out there: it doesn't has a concept of line-buffering, so native win32 should use "no" here, but I'm *hoping* MinGW transparently handles this nonsense. --- reader.lua | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/reader.lua b/reader.lua index 0017c9f2c..dc78584db 100755 --- a/reader.lua +++ b/reader.lua @@ -1,24 +1,7 @@ #!./luajit -- Enforce line-buffering for stdout (this is the default if it points to a tty, but we redirect to a file on most platforms). -local ffi = require("ffi") -local C = ffi.C - --- macOS is a special snowflake -if ffi.os == "OSX" then - ffi.cdef[[ -extern struct _IO_FILE *__stdoutp; -void setlinebuf(struct _IO_FILE *); -]] - C.setlinebuf(C.__stdoutp) -else - ffi.cdef[[ -extern struct _IO_FILE *stdout; -void setlinebuf(struct _IO_FILE *); -]] - C.setlinebuf(C.stdout) -end - +io.stdout:setvbuf("line") -- Enforce a reliable locale for numerical representations os.setlocale("C", "numeric")