Fixed invalid applying of define replacements
This commit is contained in:
parent
557313ae1e
commit
867faef496
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user