aboutsummaryrefslogtreecommitdiffhomepage
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
parent6e6971606d9613f6b5aa1df9ecf68327d079c2cc (diff)
downloadHyprland-ef80a69399d1a5139dd29b77434a750d3da0650c.tar.gz
Hyprland-ef80a69399d1a5139dd29b77434a750d3da0650c.zip
config: fix long variables being substrd
-rw-r--r--src/config/ConfigManager.cpp14
-rw-r--r--src/config/ConfigManager.hpp4
2 files changed, 11 insertions, 7 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.";
}
diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp
index fd6b40af..f09241f8 100644
--- a/src/config/ConfigManager.hpp
+++ b/src/config/ConfigManager.hpp
@@ -187,7 +187,7 @@ class CConfigManager {
private:
std::deque<std::string> configPaths; // stores all the config paths
std::unordered_map<std::string, time_t> configModifyTimes; // stores modify times
- std::unordered_map<std::string, std::string> configDynamicVars; // stores dynamic vars declared by the user
+ std::vector<std::pair<std::string, std::string>> configDynamicVars; // stores dynamic vars declared by the user
std::unordered_map<std::string, SConfigValue> configValues;
std::unordered_map<std::string, std::unordered_map<std::string, SConfigValue>> deviceConfigs; // stores device configs
@@ -215,7 +215,7 @@ class CConfigManager {
bool firstExecDispatched = false;
std::deque<std::string> firstExecRequests;
- std::unordered_map<std::string, std::string> environmentVariables;
+ std::vector<std::pair<std::string, std::string>> environmentVariables;
// internal methods
void setDefaultVars();