1
0
mirror of synced 2024-12-01 02:37:18 +01:00

Fixed invalid applying of define replacements

This commit is contained in:
WerWolv 2021-01-10 22:52:58 +01:00
parent 557313ae1e
commit 867faef496

View File

@ -172,7 +172,13 @@ namespace hex::lang {
if (initialRun) { if (initialRun) {
// Apply defines // Apply defines
for (const auto &[define, value] : this->m_defines) { std::vector<std::pair<std::string, std::string>> sortedDefines;
std::copy(this->m_defines.begin(), this->m_defines.end(), std::back_inserter(sortedDefines));
std::sort(sortedDefines.begin(), sortedDefines.end(), [](const auto &left, const auto &right) {
return left.first.size() > right.first.size();
});
for (const auto &[define, value] : sortedDefines) {
s32 index = 0; s32 index = 0;
while((index = output.find(define, index)) != std::string::npos) { while((index = output.find(define, index)) != std::string::npos) {
output.replace(index, define.length(), value); output.replace(index, define.length(), value);