mirror of
https://github.com/microtherion/VocalEasel.git
synced 2024-12-22 19:23:59 +00:00
Need to quote and escape in some further situations
This commit is contained in:
parent
f0b6bdf907
commit
782b37d572
|
@ -202,10 +202,12 @@ static std::string LilypondPitchName(int8_t pitch, bool useSharps)
|
||||||
|
|
||||||
static std::string EscapeSyllable(std::string syll)
|
static std::string EscapeSyllable(std::string syll)
|
||||||
{
|
{
|
||||||
|
bool seenAlpha = false;
|
||||||
for (size_t i=0; i<syll.size(); ++i)
|
for (size_t i=0; i<syll.size(); ++i)
|
||||||
if (isalpha(syll[i]))
|
if (isalpha(syll[i])) {
|
||||||
|
seenAlpha = true;
|
||||||
continue;
|
continue;
|
||||||
else
|
} else {
|
||||||
switch (syll[i]) {
|
switch (syll[i]) {
|
||||||
case '-':
|
case '-':
|
||||||
case ':':
|
case ':':
|
||||||
|
@ -214,10 +216,13 @@ static std::string EscapeSyllable(std::string syll)
|
||||||
case ';':
|
case ';':
|
||||||
case '\'':
|
case '\'':
|
||||||
case '_':
|
case '_':
|
||||||
|
if (seenAlpha)
|
||||||
continue;
|
continue;
|
||||||
|
/* Else fall through */
|
||||||
default:
|
default:
|
||||||
goto escape;
|
goto escape;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// Purely alphabetic syllable, no need to escape.
|
// Purely alphabetic syllable, no need to escape.
|
||||||
//
|
//
|
||||||
|
@ -225,6 +230,11 @@ static std::string EscapeSyllable(std::string syll)
|
||||||
|
|
||||||
escape:
|
escape:
|
||||||
size_t q=0;
|
size_t q=0;
|
||||||
|
while ((q = syll.find_first_of('\\', q)) != std::string::npos) {
|
||||||
|
syll.replace(q, 1, "\\\\", 2);
|
||||||
|
q += 2;
|
||||||
|
}
|
||||||
|
q = 0;
|
||||||
while ((q = syll.find_first_of('"', q)) != std::string::npos) {
|
while ((q = syll.find_first_of('"', q)) != std::string::npos) {
|
||||||
syll.replace(q, 1, "\\\"", 2);
|
syll.replace(q, 1, "\\\"", 2);
|
||||||
q += 2;
|
q += 2;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user