mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 14:58:46 +00:00
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.
This commit is contained in:
parent
7540203ae8
commit
edd8abc4cf
Notes:
sideshowbarker
2024-07-19 07:23:09 +09:00
Author: https://github.com/bcoles
Commit: edd8abc4cf
Pull-request: https://github.com/SerenityOS/serenity/pull/1924
1 changed files with 4 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue