Change auto.lua to remove comments and unneeded whitespaces before converting to hex

This commit is contained in:
vrld
2011-02-20 22:03:14 +01:00
parent 610b89cd19
commit 8581efae07
4 changed files with 7644 additions and 8140 deletions
+9 -2
View File
@@ -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