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.
pull/9641/head
NiLuJe 2 years ago committed by GitHub
parent d9eb6e9717
commit 741562e84c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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")

Loading…
Cancel
Save