patch IniFile's Lua implementation to have # comment support. Could potentially be breaking, but I'm unaware of any INI files that try to use tags that start with #.

This commit is contained in:
Flameshadowxeroshin
2013-01-27 00:02:35 -06:00
parent 1bf8e07584
commit 4db3e51a03
+16 -13
View File
@@ -64,20 +64,23 @@ IniFile =
while not file:AtEOF() do
local str = file:GetLine()
--ignore comments.
if not str:find("^%s*#") then
-- is this a section?
local _, _, sec = str:find( "%[(.+)%]" )
-- is this a section?
local _, _, sec = str:find( "%[(.+)%]" )
-- if so, set focus there; otherwise, try to
-- read a key/value pair (ignore blank lines)
if sec then
-- if this section doesn't exist, create it
tbl[sec] = tbl[sec] and tbl[sec] or { }
current = tbl[sec]
--Warn( "Switching section to " .. sec )
else
local k, v = IniFile.StrToKeyVal( str )
if k and v then current[k] = v end
-- if so, set focus there; otherwise, try to
-- read a key/value pair (ignore blank lines)
if sec then
-- if this section doesn't exist, create it
tbl[sec] = tbl[sec] and tbl[sec] or { }
current = tbl[sec]
--Warn( "Switching section to " .. sec )
else
local k, v = IniFile.StrToKeyVal( str )
if k and v then current[k] = v end
end
end
end