From 69372660b56406b797472f09da44875bb24438ad Mon Sep 17 00:00:00 2001 From: "Henry So, Jr." Date: Thu, 18 Aug 2016 23:04:40 -0400 Subject: [PATCH] Suppressed \GreLastOfScore if only no-element syllables follow it. Fixes #1205. --- CHANGELOG.md | 1 + src/gregoriotex/gregoriotex-write.c | 27 +++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a7e2076f..b9ff5729c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ As of v3.0.0 this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - When the note after an oriscus is at the same pitch, the oriscus will now point downwards by default (see [#1177](https://github.com/gregorio-project/gregorio/issues/1177)). - With thanks to Claudio Beccari (@OldClaudio), adding a commentary no longer generates a bad `\hbox` during TeX processing (see [#1202](https://github.com/gregorio-project/gregorio/issues/1202)). +- When the last note in a score is not in the last syllable, it no longer merges into the (no-note) syllable(s) that follow (see [#1205](https://github.com/gregorio-project/gregorio/issues/1205)). ### Changed - In order to facilitate installation alongside TeX Live, the version number is now appended to the gregorio executable file name. If you are running the executable directly in your custom scripts, you will need to change them to include the version number. If you are not using the TeX-Live-packaged version of Gregorio, you will probably need to use the `--shell-escape` option when compiling your `.tex` files. Note that in TeX Live 2016, which includes Gregorio 4.1.1, the executable filename does not include the version number, though that will change starting with TeX Live 2017. See UPGRADE.md and [#1197](https://github.com/gregorio-project/gregorio/issues/1197) for more information. diff --git a/src/gregoriotex/gregoriotex-write.c b/src/gregoriotex/gregoriotex-write.c index 5a7770ce4..d34af2eaa 100644 --- a/src/gregoriotex/gregoriotex-write.c +++ b/src/gregoriotex/gregoriotex-write.c @@ -3601,11 +3601,30 @@ static __inline unsigned int count_note_units(const gregorio_element *element) } static __inline void handle_last_of_voice(FILE *const f, + const gregorio_syllable *syllable, const gregorio_element *const element, const gregorio_element *const last_of_voice) { if (element == last_of_voice) { - fprintf(f, "\\GreLastOfScore"); + if (syllable->next_syllable) { + /* check for no-element syllables that follow */ + for (syllable = syllable->next_syllable; + syllable && (!syllable->elements || !*(syllable->elements)); + syllable = syllable->next_syllable) { + /* just loop */ + } + /* if syllable is NULL here, then all syllables that follow + * have no elements */ + } + /* emit GreLastOfScore if we are either on the last syllable (and + * thus the loop above is not executed, leaving syllable at the + * current syllable) or if a syllable which follows the current + * syllable has an element of some sort (and thus the loop above + * stopped before running out of syllables); in any case, the check + * is that syllable, at this point, is not NULL */ + if (syllable) { + fprintf(f, "\\GreLastOfScore"); + } } } @@ -3906,7 +3925,7 @@ static void write_syllable(FILE *f, gregorio_syllable *syllable, * We don't print custos before a bar at the end of a line */ /* we also print an unbreakable larger space before the custo */ - handle_last_of_voice(f, element, *last_of_voice); + handle_last_of_voice(f, syllable, element, *last_of_voice); next_note_pitch = gregorio_determine_next_pitch(syllable, element, NULL, &next_note_alteration); if (!element->u.misc.pitched.force_pitch) { @@ -3920,7 +3939,7 @@ static void write_syllable(FILE *f, gregorio_syllable *syllable, break; case GRE_BAR: - handle_last_of_voice(f, element, *last_of_voice); + handle_last_of_voice(f, syllable, element, *last_of_voice); write_bar(f, score, syllable, element, first_of_disc); break; @@ -3942,7 +3961,7 @@ static void write_syllable(FILE *f, gregorio_syllable *syllable, default: /* here current_element->type is GRE_ELEMENT */ assert(element->type == GRE_ELEMENT); - handle_last_of_voice(f, element, *last_of_voice); + handle_last_of_voice(f, syllable, element, *last_of_voice); note_unit_count += write_element(f, syllable, element, status, score); if (element->next && (element->next->type == GRE_ELEMENT