aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/config/ConfigManager.cpp
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2023-03-18 14:57:59 +0000
committervaxerski <[email protected]>2023-03-18 14:57:59 +0000
commitef80a69399d1a5139dd29b77434a750d3da0650c (patch)
tree7f68e3b80a700dba490c01f5240e1049d9fbf79c /src/config/ConfigManager.cpp
parent6e6971606d9613f6b5aa1df9ecf68327d079c2cc (diff)
downloadHyprland-ef80a69399d1a5139dd29b77434a750d3da0650c.tar.gz
Hyprland-ef80a69399d1a5139dd29b77434a750d3da0650c.zip
config: fix long variables being substrd
Diffstat (limited to 'src/config/ConfigManager.cpp')
-rw-r--r--src/config/ConfigManager.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index 3c75dc85..e261d699 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -40,11 +40,13 @@ CConfigManager::CConfigManager() {
void CConfigManager::populateEnvironment() {
environmentVariables.clear();
for (char** env = environ; *env; ++env) {
- const std::string ENVVAR = *env;
- const auto VARIABLE = ENVVAR.substr(0, ENVVAR.find_first_of('='));
- const auto VALUE = ENVVAR.substr(ENVVAR.find_first_of('=') + 1);
- environmentVariables[VARIABLE] = VALUE;
+ const std::string ENVVAR = *env;
+ const auto VARIABLE = ENVVAR.substr(0, ENVVAR.find_first_of('='));
+ const auto VALUE = ENVVAR.substr(ENVVAR.find_first_of('=') + 1);
+ environmentVariables.emplace_back(std::make_pair<>(VARIABLE, VALUE));
}
+
+ std::sort(environmentVariables.begin(), environmentVariables.end(), [&](const auto& a, const auto& b) { return a.first.length() > b.first.length(); });
}
void CConfigManager::setDefaultVars() {
@@ -293,7 +295,9 @@ void CConfigManager::configSetValueSafe(const std::string& COMMAND, const std::s
if (COMMAND[0] == '$') {
// register a dynamic var
Debug::log(LOG, "Registered dynamic var \"%s\" -> %s", COMMAND.c_str(), VALUE.c_str());
- configDynamicVars[COMMAND.substr(1)] = VALUE;
+ configDynamicVars.emplace_back(std::make_pair<>(COMMAND.substr(1), VALUE));
+
+ std::sort(configDynamicVars.begin(), configDynamicVars.end(), [&](const auto& a, const auto& b) { return a.first.length() > b.first.length(); });
} else {
parseError = "Error setting value <" + VALUE + "> for field <" + COMMAND + ">: No such field.";
}