Skip to content

Commit

Permalink
fixed musescore#15897: The C++ standard library's regex implementatio…
Browse files Browse the repository at this point in the history
…n does not support lookarounds
  • Loading branch information
Eism committed Jan 23, 2023
1 parent c072186 commit ecc56ff
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/engraving/libmscore/harmony.cpp
Expand Up @@ -2104,11 +2104,12 @@ String Harmony::generateScreenReaderInfo() const
{ u"i", u"1" },
};
static std::vector<std::pair<String, String> > symbolReplacements {
{ u"b", u"" },
{ u"h", u"" },
{ u"#", u"" },
{ u"bb", u"𝄫" },
{ u"##", u"𝄪" },
{ u"b", u"" }, // also replace b with ♭ for \b
{ u"\\", u"b" }, // \b should be b, so need to correct replacing in the previous step
// TODO: use SMuFL glyphs and translate
//{ "o", ""},
//{ "0", ""},
Expand All @@ -2119,10 +2120,7 @@ String Harmony::generateScreenReaderInfo() const
aux.replace(r.first, r.second);
}
for (auto const& r : symbolReplacements) {
// only replace when not preceded by backslash
String s = u"(?<!\\\\)" + r.first;
std::regex re(s.toStdString());
aux.replace(re, r.second);
aux.replace(r.first, r.second);
}
// construct string one character at a time
for (size_t i = 0; i < aux.size(); ++i) {
Expand Down

0 comments on commit ecc56ff

Please sign in to comment.