From fccd789bbf541302533ca5c4ae75ce56b7d371db Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 4 Mar 2021 22:14:54 +0000 Subject: gregorio-6.0.0-beta2 git-svn-id: svn://tug.org/texlive/trunk@58126 c570f23f-e606-0410-a88d-b1316a301751 --- .../src/gabc/gabc-score-determination.c | 33 +++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-score-determination.c') 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; + } + } +} -- cgit v1.2.3