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:
@@ -65,19 +65,22 @@ IniFile =
|
|||||||
while not file:AtEOF() do
|
while not file:AtEOF() do
|
||||||
local str = file:GetLine()
|
local str = file:GetLine()
|
||||||
|
|
||||||
-- is this a section?
|
--ignore comments.
|
||||||
local _, _, sec = str:find( "%[(.+)%]" )
|
if not str:find("^%s*#") then
|
||||||
|
-- is this a section?
|
||||||
|
local _, _, sec = str:find( "%[(.+)%]" )
|
||||||
|
|
||||||
-- if so, set focus there; otherwise, try to
|
-- if so, set focus there; otherwise, try to
|
||||||
-- read a key/value pair (ignore blank lines)
|
-- read a key/value pair (ignore blank lines)
|
||||||
if sec then
|
if sec then
|
||||||
-- if this section doesn't exist, create it
|
-- if this section doesn't exist, create it
|
||||||
tbl[sec] = tbl[sec] and tbl[sec] or { }
|
tbl[sec] = tbl[sec] and tbl[sec] or { }
|
||||||
current = tbl[sec]
|
current = tbl[sec]
|
||||||
--Warn( "Switching section to " .. sec )
|
--Warn( "Switching section to " .. sec )
|
||||||
else
|
else
|
||||||
local k, v = IniFile.StrToKeyVal( str )
|
local k, v = IniFile.StrToKeyVal( str )
|
||||||
if k and v then current[k] = v end
|
if k and v then current[k] = v end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user