count braces while passing format in the loop to omit nested ones
This commit is contained in:
22
src/song.cpp
22
src/song.cpp
@@ -371,9 +371,16 @@ std::string MPD::Song::Format_ParseBraces(std::string::const_iterator &it, std::
|
|||||||
else
|
else
|
||||||
result += *it;
|
result += *it;
|
||||||
}
|
}
|
||||||
|
int brace_counter = 0;
|
||||||
if (*it != '}' || !has_some_tags)
|
if (*it != '}' || !has_some_tags)
|
||||||
{
|
{
|
||||||
for (; *it != '}'; ++it) { }
|
for (; *it != '}' || brace_counter; ++it)
|
||||||
|
{
|
||||||
|
if (*it == '{')
|
||||||
|
++brace_counter;
|
||||||
|
else if (*it == '}')
|
||||||
|
--brace_counter;
|
||||||
|
}
|
||||||
if (*++it == '|')
|
if (*++it == '|')
|
||||||
return Format_ParseBraces(++it, end_it);
|
return Format_ParseBraces(++it, end_it);
|
||||||
else
|
else
|
||||||
@@ -381,8 +388,17 @@ std::string MPD::Song::Format_ParseBraces(std::string::const_iterator &it, std::
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (*++it == '|')
|
if (*(it+1) == '|')
|
||||||
for (; *it != '}' || *++it == '|'; ++it) { }
|
{
|
||||||
|
for (; *it != '}' || *(it+1) == '|' || brace_counter; ++it)
|
||||||
|
{
|
||||||
|
if (*it == '{')
|
||||||
|
++brace_counter;
|
||||||
|
else if (*it == '}')
|
||||||
|
--brace_counter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++it;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user