diff --git a/src/iohumdrum.cpp b/src/iohumdrum.cpp index cb6360ac24e..8b8eefe877b 100644 --- a/src/iohumdrum.cpp +++ b/src/iohumdrum.cpp @@ -6820,7 +6820,7 @@ void HumdrumInput::setTimeSig(StaffDef *part, const std::string ×ig, const vrvmeter->SetVisible(BOOLEAN_false); } } - if (timetok->find("yy") != std::string::npos) { + if (timetok && timetok->find("yy") != std::string::npos) { vrvmeter->SetVisible(BOOLEAN_false); } @@ -24880,8 +24880,8 @@ template void HumdrumInput::convertVerses(ELEMENT element, hum:: hre.replaceDestructive(value, "ü", "u2", "g"); // u-umlaut hre.replaceDestructive(value, "ä", "a2", "g"); // a-umlaut hre.replaceDestructive(value, "ö", "o2", "g"); // o-umlaut - hre.replaceDestructive(value, "\\s+$", ""); // trailing spaces - hre.replaceDestructive(value, "^\\s+", ""); // leading spaces + hre.replaceDestructive(value, "", "\\s+$"); // trailing spaces + hre.replaceDestructive(value, "", "^\\s+"); // leading spaces hre.replaceDestructive(value, "-", "\\s+-$"); // trailing space before hyphen hre.replaceDestructive(value, "-", "^-\\s+"); // leaning spaces after hyphen if (!value.empty()) { @@ -25353,6 +25353,7 @@ template void HumdrumInput::setRhythmFromDuration(ELEMENT elemen template void HumdrumInput::setVisualAndGesturalRhythmFromDuration(ELEMENT element, hum::HumNum visdur, hum::HumNum gesdur) { + bool durGesSet = false; pair visDurAndDots = getDurAndDots(visdur); element->SetDur(visDurAndDots.first); if (visDurAndDots.second != 0) { @@ -25361,8 +25362,14 @@ void HumdrumInput::setVisualAndGesturalRhythmFromDuration(ELEMENT element, hum:: pair gesDurAndDots = getDurAndDots(gesdur); if (gesDurAndDots.first != visDurAndDots.first) { element->SetDurGes(gesDurAndDots.first); + durGesSet = true; + } + if (!durGesSet) { + if (gesDurAndDots.second != visDurAndDots.second) { + element->SetDotsGes(gesDurAndDots.second); + } } - if (gesDurAndDots.second != visDurAndDots.second) { + else { element->SetDotsGes(gesDurAndDots.second); } } @@ -25419,14 +25426,15 @@ template hum::HumNum HumdrumInput::convertRhythm(ELEMENT element if (!vstring.empty()) { int visualdotcount = characterCountInSubtoken(vstring, '.'); - if (visualdotcount > 0) { - element->SetDots(visualdotcount); - } int gesturaldotcount = characterCountInSubtoken(tstring, '.'); - if (gesturaldotcount != visualdotcount) { - element->SetDotsGes(gesturaldotcount); + // It would be prettier to avoid @dots.ges="0" if @dots is not set, + // but we cannot tell from here whether @dots will be set (the + // call to setRhythmFromDuration() can set @dots unexpectedly). + // So we always set @dots.ges if @dur.ges is going to be set. + if (visualdotcount != 0) { element->SetDots(visualdotcount); } + element->SetDotsGes(gesturaldotcount); } else { int dotcount = characterCountInSubtoken(tstring, '.'); @@ -25450,9 +25458,10 @@ template hum::HumNum HumdrumInput::convertRhythm(ELEMENT element dur /= 4; // convert duration to whole-note units int logicaldurdots = (int)std::count(logicaldur.begin(), logicaldur.end(), '.'); int visualdurdots = (int)std::count(visualdur.begin(), visualdur.end(), '.'); - if (visualdurdots != logicaldurdots) { - element->SetDotsGes(logicaldurdots); + if (visualdurdots != 0) { + element->SetDots(visualdurdots); } + element->SetDotsGes(logicaldurdots); std::string typestring = token->getValue("auto", "MEI", "type"); if (typestring.empty()) { element->SetType("overfill");