summaryrefslogtreecommitdiff
path: root/Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-score-determination.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-score-determination.c')
-rw-r--r--Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-score-determination.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-score-determination.c b/Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-score-determination.c
index 38b88ad4799..31a69c8ccde 100644
--- a/Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-score-determination.c
+++ b/Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-score-determination.c
@@ -3,7 +3,7 @@
* This file implements the score parser.
*
* Gregorio score determination from gabc utilities.
- * Copyright (C) 2016-2019 The Gregorio Project (see CONTRIBUTORS.md)
+ * Copyright (C) 2016-2021 The Gregorio Project (see CONTRIBUTORS.md)
*
* This file is part of Gregorio.
*
@@ -657,3 +657,34 @@ void gabc_determine_ledger_lines(const gregorio_score *const score)
/* stacks should be cleared by ledger_line_end_item */
}
+
+char *gabc_unescape(const char *const string)
+{
+ /*
+ * in this context, unescape means to discard any special meaning of a
+ * character that follows a backslash. Thus backslash-{something} is
+ * reduced to {something}
+ */
+ char *result, *to;
+ const char *from = string;
+ int len = 1;
+ result = to = (char *)gregorio_malloc(strlen(string) + 1);
+
+ for (;;) {
+ if (*from == '\0') {
+ *to = *from;
+ return (char *)gregorio_realloc(result, len);
+ } else if (*from == '$') {
+ *to = *(++ from);
+ if (*from == '\0') {
+ return (char *)gregorio_realloc(result, len);
+ }
+ ++ to;
+ ++ from;
+ ++ len;
+ } else {
+ *(to ++) = *(from ++);
+ ++len;
+ }
+ }
+}