|
@@ -60,6 +60,11 @@ local function savefile(name, mode)
|
|
return check(io.open(name, mode))
|
|
return check(io.open(name, mode))
|
|
end
|
|
end
|
|
|
|
|
|
|
|
+local function set_stdout_binary(ffi)
|
|
|
|
+ ffi.cdef[[int _setmode(int fd, int mode);]]
|
|
|
|
+ ffi.C._setmode(1, 0x8000)
|
|
|
|
+end
|
|
|
|
+
|
|
------------------------------------------------------------------------------
|
|
------------------------------------------------------------------------------
|
|
|
|
|
|
local map_type = {
|
|
local map_type = {
|
|
@@ -125,6 +130,11 @@ local function bcsave_tail(fp, output, s)
|
|
end
|
|
end
|
|
|
|
|
|
local function bcsave_raw(output, s)
|
|
local function bcsave_raw(output, s)
|
|
|
|
+ if output == "-" and jit.os == "Windows" then
|
|
|
|
+ local ok, ffi = pcall(require, "ffi")
|
|
|
|
+ check(ok, "FFI library required to write binary file to stdout")
|
|
|
|
+ set_stdout_binary(ffi)
|
|
|
|
+ end
|
|
local fp = savefile(output, "wb")
|
|
local fp = savefile(output, "wb")
|
|
bcsave_tail(fp, output, s)
|
|
bcsave_tail(fp, output, s)
|
|
end
|
|
end
|
|
@@ -568,6 +578,9 @@ end
|
|
local function bcsave_obj(ctx, output, s)
|
|
local function bcsave_obj(ctx, output, s)
|
|
local ok, ffi = pcall(require, "ffi")
|
|
local ok, ffi = pcall(require, "ffi")
|
|
check(ok, "FFI library required to write this file type")
|
|
check(ok, "FFI library required to write this file type")
|
|
|
|
+ if output == "-" and jit.os == "Windows" then
|
|
|
|
+ set_stdout_binary(ffi)
|
|
|
|
+ end
|
|
if ctx.os == "windows" then
|
|
if ctx.os == "windows" then
|
|
return bcsave_peobj(ctx, output, s, ffi)
|
|
return bcsave_peobj(ctx, output, s, ffi)
|
|
elseif ctx.os == "osx" then
|
|
elseif ctx.os == "osx" then
|