summaryrefslogtreecommitdiff
path: root/Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-write.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-write.c')
-rw-r--r--Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-write.c145
1 files changed, 113 insertions, 32 deletions
diff --git a/Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-write.c b/Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-write.c
index a6be28bad4a..7e5985de97c 100644
--- a/Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-write.c
+++ b/Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-write.c
@@ -2,7 +2,7 @@
* Gregorio is a program that translates gabc files to GregorioTeX
* This file provides functions for writing gabc from Gregorio structures.
*
- * Copyright (C) 2006-2019 The Gregorio Project (see CONTRIBUTORS.md)
+ * Copyright (C) 2006-2021 The Gregorio Project (see CONTRIBUTORS.md)
*
* This file is part of Gregorio.
*
@@ -39,7 +39,8 @@
typedef enum {
GABC_NORMAL,
GABC_AT_PROTRUSION_FACTOR,
- GABC_IN_PROTRUSION_FACTOR
+ GABC_IN_PROTRUSION_FACTOR,
+ GABC_IN_AUTO_PROTRUSION
} gabc_write_state;
static gabc_write_state write_state;
@@ -189,6 +190,80 @@ static void gabc_write_end(FILE *f, grestyle_style style)
/*
*
+ * The function called when we will encounter a character. There may be other
+ * representations of the character (for example for Omega), so it is necessary
+ * to have such a function defined in each module.
+ *
+ */
+
+static void gabc_print_char(FILE *f, const grewchar to_print)
+{
+ if (write_state == GABC_AT_PROTRUSION_FACTOR) {
+ write_state = GABC_IN_PROTRUSION_FACTOR;
+ if (to_print == 'd') {
+ fprintf(f, "<pr");
+ } else {
+ fprintf(f, "<pr:");
+ gregorio_print_unichar(f, to_print);
+ }
+ } else {
+ switch(to_print) {
+ case ',':
+ case ';':
+ case ':':
+ case '.':
+ if (write_state == GABC_IN_AUTO_PROTRUSION) {
+ break;
+ }
+ /* fall through */
+ case '-':
+ case '{':
+ case '}':
+ case '(':
+ case ')':
+ case '[':
+ case ']':
+ case '|':
+ case '<':
+ case '%':
+ case '$':
+ gregorio_print_unichar(f, '$');
+ break;
+ }
+ gregorio_print_unichar(f, to_print);
+ }
+}
+
+/*
+ *
+ * This function writes a unicode string as gregorio_print_unistring, but
+ * handles escapes using gabc_print_char.
+ *
+ */
+static void gabc_print_unistring(FILE *f, const grewchar *first_char)
+{
+ while (*first_char != 0) {
+ gabc_print_char(f, *first_char);
+ first_char++;
+ }
+}
+
+/*
+ *
+ * This function writes a null-terminated string as gregorio_print_unistring,
+ * but handles escapes using gabc_print_char.
+ *
+ */
+static void gabc_print_string(FILE *f, const char *first_char)
+{
+ while (*first_char != '\0') {
+ gabc_print_char(f, (grewchar)*first_char);
+ first_char++;
+ }
+}
+
+/*
+ *
* This function writes the special chars. As the specials chars are
* represented simply in gabc, this function is very simple, but for TeX output
* modules, this may be.. a little more difficult.
@@ -197,7 +272,7 @@ static void gabc_write_end(FILE *f, grestyle_style style)
static void gabc_write_special_char(FILE *f, const grewchar *first_char)
{
fprintf(f, "<sp>");
- gregorio_print_unistring(f, first_char);
+ gabc_print_unistring(f, first_char);
fprintf(f, "</sp>");
}
@@ -211,39 +286,16 @@ static void gabc_write_verb(FILE *f, const grewchar *first_char)
{
if (write_state == GABC_AT_PROTRUSION_FACTOR) {
/* this is an auto protrusion, so ignore it */
- write_state = GABC_NORMAL;
+ write_state = GABC_IN_AUTO_PROTRUSION;
} else {
fprintf(f, "<v>");
- gregorio_print_unistring(f, first_char);
+ gabc_print_unistring(f, first_char);
fprintf(f, "</v>");
}
}
/*
*
- * The function called when we will encounter a character. There may be other
- * representations of the character (for example for Omega), so it is necessary
- * to have such a function defined in each module.
- *
- */
-
-static void gabc_print_char(FILE *f, const grewchar to_print)
-{
- if (write_state == GABC_AT_PROTRUSION_FACTOR) {
- write_state = GABC_IN_PROTRUSION_FACTOR;
- if (to_print == 'd') {
- fprintf(f, "<pr");
- } else {
- fprintf(f, "<pr:");
- gregorio_print_unichar(f, to_print);
- }
- } else {
- gregorio_print_unichar(f, to_print);
- }
-}
-
-/*
- *
* Quite important: the function that writes the liquescentia. It is called at
* the end of the function that writes one glyph.
*
@@ -392,6 +444,18 @@ static void gabc_write_bar(FILE *f, gregorio_bar type)
case B_DIVISIO_MINIMIS_HIGH:
fprintf(f, "^0");
break;
+ case B_VIRGULA_PAREN:
+ fprintf(f, "`?");
+ break;
+ case B_VIRGULA_PAREN_HIGH:
+ fprintf(f, "`0?");
+ break;
+ case B_DIVISIO_MINIMA_PAREN:
+ fprintf(f, ",?");
+ break;
+ case B_DIVISIO_MINIMA_PAREN_HIGH:
+ fprintf(f, ",0?");
+ break;
default:
/* not reachable unless there's a programming error */
/* LCOV_EXCL_START */
@@ -564,12 +628,21 @@ static void gabc_write_gregorio_note(FILE *f, gregorio_note *note,
case S_FLAT:
fprintf(f, "%cx", pitch_letter(note->u.note.pitch));
break;
+ case S_FLAT_PAREN:
+ fprintf(f, "%cx?", pitch_letter(note->u.note.pitch));
+ break;
case S_NATURAL:
fprintf(f, "%cy", pitch_letter(note->u.note.pitch));
break;
+ case S_NATURAL_PAREN:
+ fprintf(f, "%cy?", pitch_letter(note->u.note.pitch));
+ break;
case S_SHARP:
fprintf(f, "%c#", pitch_letter(note->u.note.pitch));
break;
+ case S_SHARP_PAREN:
+ fprintf(f, "%c#?", pitch_letter(note->u.note.pitch));
+ break;
case S_VIRGA:
fprintf(f, "%cv", pitch_letter(note->u.note.pitch));
break;
@@ -701,7 +774,9 @@ static void gabc_write_gregorio_note(FILE *f, gregorio_note *note,
}
write_note_heuristics(f, note);
if (note->texverb) {
- fprintf(f, "[nv:%s]", gregorio_texverb(note->texverb));
+ fprintf(f, "[nv:");
+ gabc_print_string(f, gregorio_texverb(note->texverb));
+ fprintf(f, "]");
}
}
@@ -859,7 +934,9 @@ static void gabc_write_gregorio_glyph(FILE *f, gregorio_glyph *glyph,
switch (glyph->type) {
case GRE_TEXVERB_GLYPH:
if (glyph->texverb) {
- fprintf(f, "[gv:%s]", gregorio_texverb(glyph->texverb));
+ fprintf(f, "[gv:");
+ gabc_print_string(f, gregorio_texverb(glyph->texverb));
+ fprintf(f, "]");
}
break;
case GRE_SPACE:
@@ -965,12 +1042,16 @@ static void gabc_write_gregorio_element(FILE *f, gregorio_element *element,
break;
case GRE_TEXVERB_ELEMENT:
if (element->texverb) {
- fprintf(f, "[ev:%s]", gregorio_texverb(element->texverb));
+ fprintf(f, "[ev:");
+ gabc_print_string(f, gregorio_texverb(element->texverb));
+ fprintf(f, "]");
}
break;
case GRE_ALT:
if (element->texverb) {
- fprintf(f, "[alt:%s]", gregorio_texverb(element->texverb));
+ fprintf(f, "[alt:");
+ gabc_print_string(f, gregorio_texverb(element->texverb));
+ fprintf(f, "]");
}
break;
case GRE_SPACE: