mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-25 22:05:59 +01:00
config: fix long variables being substrd
This commit is contained in:
parent
6e6971606d
commit
ef80a69399
2 changed files with 11 additions and 7 deletions
|
@ -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.";
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue