From 666cdb40bd78869eaee8dd42113c82f56c2a6a40 Mon Sep 17 00:00:00 2001 From: Dan Guzek Date: Mon, 6 Apr 2015 21:01:52 -0400 Subject: [PATCH] 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. --- Themes/_fallback/Scripts/01 IniFile.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Themes/_fallback/Scripts/01 IniFile.lua b/Themes/_fallback/Scripts/01 IniFile.lua index c01743dd4d..e99c918e46 100644 --- a/Themes/_fallback/Scripts/01 IniFile.lua +++ b/Themes/_fallback/Scripts/01 IniFile.lua @@ -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