mirror of
https://github.com/love2d/love.git
synced 2026-08-14 10:13:46 +02:00
Change auto.lua to remove comments and unneeded whitespaces before converting to hex
This commit is contained in:
@@ -15,7 +15,11 @@ function auto(name)
|
||||
-- Read source Lua file
|
||||
local src_file = io.open(src, "rb")
|
||||
local src_data = src_file:read("*a")
|
||||
local src_len = #src_data
|
||||
-- remove comments
|
||||
src_data = src_data:gsub("%-%-%[%[.-%-%-%]%]", ""):gsub("%-%-.-\n", "")
|
||||
-- remove unneeded whitespaces
|
||||
src_data = src_data:gsub("^%s+",""):gsub("%s*$",""):gsub("%s%s+", " ")
|
||||
local src_len = #src_data
|
||||
src_file:close()
|
||||
|
||||
local lines = {}
|
||||
@@ -87,7 +91,10 @@ if #arg == 0 then
|
||||
print("Usage: lua auto.lua <name1> <name2> .. <name3>")
|
||||
else
|
||||
for i, v in ipairs(arg) do
|
||||
auto(v)
|
||||
local ok, err = pcall(auto, v:gsub("%.lua$",""))
|
||||
if not ok then
|
||||
print("cannot update "..v..": " .. err)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user