made loadfile standard lua conformant in that it skips the first line in a file if it starts with a #

This commit is contained in:
Florian Nücke 2014-01-28 00:08:07 +01:00
parent 982624503d
commit a88f8443b1

View File

@ -16,6 +16,14 @@ function loadfile(filename, mode, env)
if not source then
return nil, reason
end
if string.sub(source, 1, 1) == "#" then
local endline = string.find(source, "\n", 2, true)
if endline then
source = string.sub(source, endline + 1)
else
source = ""
end
end
return load(source, "=" .. filename, mode, env)
end