|
|
@ -3,11 +3,21 @@
|
|
|
|
-- Enforce line-buffering for stdout (this is the default if it points to a tty, but we redirect to a file on most platforms).
|
|
|
|
-- 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 ffi = require("ffi")
|
|
|
|
local C = ffi.C
|
|
|
|
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[[
|
|
|
|
ffi.cdef[[
|
|
|
|
extern struct _IO_FILE *stdout;
|
|
|
|
extern struct _IO_FILE *stdout;
|
|
|
|
void setlinebuf(struct _IO_FILE *);
|
|
|
|
void setlinebuf(struct _IO_FILE *);
|
|
|
|
]]
|
|
|
|
]]
|
|
|
|
C.setlinebuf(C.stdout)
|
|
|
|
C.setlinebuf(C.stdout)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- Enforce a reliable locale for numerical representations
|
|
|
|
-- Enforce a reliable locale for numerical representations
|
|
|
|
os.setlocale("C", "numeric")
|
|
|
|
os.setlocale("C", "numeric")
|
|
|
|