From 221f4910199b53f84794b8457a2f08e004228b91 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Mon, 25 Dec 2023 16:19:53 +0100 Subject: [PATCH] return early after reading ENV in config --- src/TConfig.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/TConfig.cpp b/src/TConfig.cpp index 11d5f79..efb18c7 100644 --- a/src/TConfig.cpp +++ b/src/TConfig.cpp @@ -175,6 +175,7 @@ void TConfig::TryReadValue(toml::value& Table, const std::string& Category, cons if (!Env.empty()) { if (const char* envp = std::getenv(Env.data()); envp != nullptr && std::strcmp(envp, "") != 0) { OutValue = std::string(envp); + return; } } if (Table[Category.c_str()][Key.data()].is_string()) { @@ -187,6 +188,7 @@ void TConfig::TryReadValue(toml::value& Table, const std::string& Category, cons if (const char* envp = std::getenv(Env.data()); envp != nullptr && std::strcmp(envp, "") != 0) { auto Str = std::string(envp); OutValue = Str == "1" || Str == "true"; + return; } } if (Table[Category.c_str()][Key.data()].is_boolean()) { @@ -198,6 +200,7 @@ void TConfig::TryReadValue(toml::value& Table, const std::string& Category, cons if (!Env.empty()) { if (const char* envp = std::getenv(Env.data()); envp != nullptr && std::strcmp(envp, "") != 0) { OutValue = int(std::strtol(envp, nullptr, 10)); + return; } } if (Table[Category.c_str()][Key.data()].is_integer()) {