mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
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.
This commit is contained in:
19
reader.lua
19
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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user