IniFile fix: checking for false ~= checking for nil

false is a perfectly valid setting for one of SM's ini files.  The code here needs to ensure that both the key (string) and the value (string, numeric, boolean) read from file exist.  It would previously halt if the value was set to false.  This fixes that by explicitly checking for nil.
This commit is contained in:
Dan Guzek
2015-04-06 21:01:52 -04:00
parent c49d78f5fc
commit 666cdb40bd
+3 -3
View File
@@ -42,7 +42,7 @@ local RageFile =
IniFile =
{
StrToKeyVal = function( str )
local _, _, key, value = str:find( "(.+)=(.*)" )
local key, value = str:match( "(.+)=(.*)" )
-- key is always a string, but value may be num, bool, or nil.
-- do a few quick checks to see which one it is.
@@ -80,7 +80,7 @@ IniFile =
--ignore comments.
if not str:find("^%s*#") then
-- is this a section?
local _, _, sec = str:find( "%[(.+)%]" )
local sec = str:match( "%[(.+)%]" )
-- if so, set focus there; otherwise, try to
-- read a key/value pair (ignore blank lines)
@@ -91,7 +91,7 @@ IniFile =
--Warn( "Switching section to " .. sec )
else
local k, v = IniFile.StrToKeyVal( str )
if k and v then current[k] = v end
if k and v ~= nil then current[k] = v end
end
end
end