Skip to content

Commit f722dc2

Browse files
committed
Fixed (fingers crossed) my commit for #7294
1 parent 6430d2d commit f722dc2

File tree

1 file changed

+30
-29
lines changed

1 file changed

+30
-29
lines changed

src/common/config/config_file.cpp

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -415,48 +415,49 @@ ConfigFile::LineType ConfigFile::parseLine(const char* fileName, const String& i
415415

416416
bool ConfigFile::macroParse(String& value, const char* fileName) const
417417
{
418+
String::size_type pos = 0;
418419
String::size_type subFrom;
419420

420-
while ((subFrom = value.find("$(")) != String::npos)
421+
while ((subFrom = value.find("$(", pos)) != String::npos)
421422
{
422423
String::size_type subTo = value.find(")", subFrom);
423-
if (subTo != String::npos)
424-
{
425-
String macro;
426-
String m = value.substr(subFrom + 2, subTo - (subFrom + 2));
427-
428-
if (!translate(fileName, m, macro))
429-
{
430-
if (flags & CUSTOM_MACROS)
431-
continue;
432-
433-
return false;
434-
}
424+
if (subTo == String::npos)
425+
return false;
435426

436-
++subTo;
427+
String macro;
428+
String m = value.substr(subFrom + 2, subTo - (subFrom + 2));
437429

438-
// Avoid incorrect slashes in pathnames
439-
PathUtils::fixupSeparators(value.begin());
440-
PathUtils::fixupSeparators(macro.begin());
430+
++subTo;
441431

442-
if (subFrom > 0 && value[subFrom - 1] == PathUtils::dir_sep &&
443-
macro.length() > 0 && macro[0] == PathUtils::dir_sep)
444-
{
445-
--subFrom;
446-
}
447-
if (subTo < value.length() && value[subTo] == PathUtils::dir_sep &&
448-
macro.length() > 0 && macro[macro.length() - 1] == PathUtils::dir_sep)
432+
if (!translate(fileName, m, macro))
433+
{
434+
if (flags & CUSTOM_MACROS)
449435
{
450-
++subTo;
436+
pos = subTo;
437+
continue;
451438
}
452439

453-
// Now perform operation
454-
value.replace(subFrom, subTo - subFrom, macro);
440+
return false;
455441
}
456-
else
442+
443+
// Avoid incorrect slashes in pathnames
444+
PathUtils::fixupSeparators(value.begin());
445+
PathUtils::fixupSeparators(macro.begin());
446+
447+
if (subFrom > 0 && value[subFrom - 1] == PathUtils::dir_sep &&
448+
macro.length() > 0 && macro[0] == PathUtils::dir_sep)
457449
{
458-
return false;
450+
--subFrom;
459451
}
452+
if (subTo < value.length() && value[subTo] == PathUtils::dir_sep &&
453+
macro.length() > 0 && macro[macro.length() - 1] == PathUtils::dir_sep)
454+
{
455+
++subTo;
456+
}
457+
458+
// Now perform operation
459+
value.replace(subFrom, subTo - subFrom, macro);
460+
pos = subFrom + macro.length();
460461
}
461462

462463
return true;

0 commit comments

Comments
 (0)