Fix inline comments in dropshell handling
This commit is contained in:
@@ -35,6 +35,26 @@ bool envmanager::load() {
|
||||
std::string key = line.substr(0, pos);
|
||||
std::string value = line.substr(pos + 1);
|
||||
|
||||
// Remove inline comments (everything after unquoted #)
|
||||
bool in_quotes = false;
|
||||
char quote_char = '\0';
|
||||
for (size_t i = 0; i < value.length(); ++i) {
|
||||
char c = value[i];
|
||||
|
||||
// Handle quote state changes
|
||||
if (!in_quotes && (c == '\'' || c == '"')) {
|
||||
in_quotes = true;
|
||||
quote_char = c;
|
||||
} else if (in_quotes && c == quote_char && (i == 0 || value[i-1] != '\\')) {
|
||||
in_quotes = false;
|
||||
quote_char = '\0';
|
||||
} else if (!in_quotes && c == '#') {
|
||||
// Found unquoted # - truncate value here
|
||||
value = value.substr(0, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// trim whitespace from the key and value
|
||||
m_variables[dequote(trim(key))] = dequote(trim(value));
|
||||
}
|
||||
|
Reference in New Issue
Block a user