Procházet zdrojové kódy

LibCore: read_bool_entry parse "true" / "false" strings in config files

`read_bool_entry()` can now interpret both integers (1 or 0) and
Boolean strings ("true" or "false") in configuration files.

All values other than "1" or "true" are considered false.
Brendan Coles před 5 roky
rodič
revize
edd8abc4cf
1 změnil soubory, kde provedl 4 přidání a 1 odebrání
  1. 4 1
      Libraries/LibCore/ConfigFile.cpp

+ 4 - 1
Libraries/LibCore/ConfigFile.cpp

@@ -138,7 +138,10 @@ int ConfigFile::read_num_entry(const String& group, const String& key, int defau
 
 bool ConfigFile::read_bool_entry(const String& group, const String& key, bool default_value) const
 {
-    return read_entry(group, key, default_value ? "1" : "0") == "1";
+    auto value = read_entry(group, key, default_value ? "1" : "0");
+    if (value == "1" || value.to_lowercase() == "true")
+        return 1;
+    return 0;
 }
 
 void ConfigFile::write_entry(const String& group, const String& key, const String& value)