From 4db3e51a039de79008b4b2b9e1a6091f90b72672 Mon Sep 17 00:00:00 2001 From: Flameshadowxeroshin Date: Sun, 27 Jan 2013 00:02:35 -0600 Subject: [PATCH] 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 #. --- Themes/_fallback/Scripts/01 IniFile.lua | 29 ++++++++++++++----------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/Themes/_fallback/Scripts/01 IniFile.lua b/Themes/_fallback/Scripts/01 IniFile.lua index 9809ac25aa..bc042bee5d 100644 --- a/Themes/_fallback/Scripts/01 IniFile.lua +++ b/Themes/_fallback/Scripts/01 IniFile.lua @@ -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