Skip to content

Commit 6ed2a47

Browse files
committed
Refactor variable names to single character to save disk space in dosfren.lua
1 parent b39cbbf commit 6ed2a47

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

demo/extra/dosfren.lua

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env lua
1+
#!/usr/bin/env lua
22

33
help = [[
44
DOS and UNIX disagree on what a new line should be
@@ -43,47 +43,47 @@ local function Shebang(inFile)
4343
return nil
4444
end
4545

46-
for i = 1, #arg do
47-
local iFile, err = io.open(arg[i])
48-
if not iFile then print(arg[i] .. ": " .. err) else
49-
local oFile
50-
oFile, err = io.open(arg[i] .. ".tmp", "wb")
51-
if not oFile then
52-
print(arg[i] .. ".tmp: " .. err)
46+
for j = 1, #arg do
47+
local i, e = io.open(arg[j])
48+
if not i then print(arg[j] .. ": " .. e) else
49+
local o
50+
o, e = io.open(arg[j] .. ".tmp", "wb")
51+
if not o then
52+
print(arg[j] .. ".tmp: " .. e)
5353
else
54-
local shebang = Shebang(iFile)
55-
if shebang then
56-
oFile:write(shebang)
54+
local s = Shebang(i)
55+
if s then
56+
o:write(s)
5757
while true do
58-
local line = iFile:read("*l")
59-
if line then
60-
oFile:write(StripCarriage(line) .. CRLF)
58+
local l = i:read("*l")
59+
if l then
60+
o:write(StripCarriage(l) .. CRLF)
6161
else
6262
break
6363
end
6464
end
65-
iFile:close() oFile:close()
65+
i:close() o:close()
6666

6767
--[[
6868
Swap the temporary file and original file around
6969
so that the original files is being copied to.
7070
This allows system file permissions to remain unchanged.
7171
--]]
7272

73-
iFile = io.open(arg[i] .. ".tmp", "rb")
74-
oFile = io.open(arg[i], "wb")
75-
if iFile and oFile then
73+
i = io.open(arg[j] .. ".tmp", "rb")
74+
o = io.open(arg[j], "wb")
75+
if i and o then
7676
while true do
77-
local data = iFile:read(1024)
78-
if not data then
77+
local d = i:read(1024)
78+
if not d then
7979
break
8080
end
81-
oFile:write(data)
81+
o:write(d)
8282
end
83-
iFile:close() oFile:close()
83+
i:close() o:close()
8484
end
8585
end
86-
os.remove(arg[i] .. ".tmp")
86+
os.remove(arg[j] .. ".tmp")
8787
end
8888
end
8989
end

0 commit comments

Comments
 (0)