Skip to content

Commit 1bae5c6

Browse files
committed
Allow script 'DOSFREN.LUA' to convert a file to CR/LF even when no unix shebang is found.
1 parent 315d403 commit 1bae5c6

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

demo/xtra/DOSFREN.LUA

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ local function Shebang(inFile)
4040
end
4141
return o
4242
end
43+
inFile:seek("set", 0)
4344
return nil
4445
end
4546

@@ -62,36 +63,34 @@ for j = 1, #arg do
6263
print(t .. ": " .. e)
6364
else
6465
local s = Shebang(i)
65-
if s then
66-
o:write(s)
67-
while true do
68-
local l = i:read("*l")
69-
if l then
70-
o:write(StripCarriage(l) .. CRLF)
71-
else
72-
break
73-
end
66+
if s then o:write(s) end
67+
while true do
68+
local l = i:read("*l")
69+
if l then
70+
o:write(StripCarriage(l) .. CRLF)
71+
else
72+
break
7473
end
75-
i:close() o:close()
74+
end
75+
i:close() o:close()
7676

77-
--[[
78-
Swap the temporary file and original file around
79-
so that the original files is being copied to.
80-
This allows system file permissions to remain unchanged.
81-
--]]
77+
--[[
78+
Swap the temporary file and original file around
79+
so that the original files is being copied to.
80+
This allows system file permissions to remain unchanged.
81+
--]]
8282

83-
i = io.open(t, "rb")
84-
o = io.open(arg[j], "wb")
85-
if i and o then
86-
while true do
87-
local d = i:read(1024)
88-
if not d then
89-
break
90-
end
91-
o:write(d)
83+
i = io.open(t, "rb")
84+
o = io.open(arg[j], "wb")
85+
if i and o then
86+
while true do
87+
local d = i:read(1024)
88+
if not d then
89+
break
9290
end
93-
i:close() o:close()
91+
o:write(d)
9492
end
93+
i:close() o:close()
9594
end
9695
os.remove(t)
9796
end

0 commit comments

Comments
 (0)