From 34657e7ea4fb1a31db40fecd557bd7038ff20b10 Mon Sep 17 00:00:00 2001 From: Juho Hiltunen Date: Sat, 22 Aug 2020 21:01:58 +0300 Subject: [PATCH] code cleanup: move check for SSML comments and declarations to ProcessSsmlTag() Note the line in readclause.c: if ((c2 == '/') || iswalpha(c2) || c2 == '!' || c2 == '?') { It might be enough to pass everything to ProcessSsmlTag. What are the cases that are skipped because of this? --- src/libespeak-ng/readclause.c | 7 +------ src/libespeak-ng/ssml.c | 5 +++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libespeak-ng/readclause.c b/src/libespeak-ng/readclause.c index e0f9fe3f..9a7cb3a4 100644 --- a/src/libespeak-ng/readclause.c +++ b/src/libespeak-ng/readclause.c @@ -753,12 +753,7 @@ int ReadClause(Translator *tr, char *buf, short *charix, int *charix_top, int n_ if ((c1 <= 0x20) && ((sayas_mode == SAYAS_SINGLE_CHARS) || (sayas_mode == SAYAS_KEY))) c1 += 0xe000; // move into unicode private usage area } else if ((c1 == '<') && (ssml_ignore_l_angle != '<')) { - if ((c2 == '!') || (c2 == '?')) { - // a comment, ignore until closing '<' (or ')) - c1 = GetC(); - c2 = ' '; - } else if ((c2 == '/') || iswalpha(c2)) { + if ((c2 == '/') || iswalpha(c2) || c2 == '!' || c2 == '?') { // check for space in the output buffer for embedded commands produced by the SSML tag if (ix > (n_buf - 20)) { // Perhaps not enough room, end the clause before the SSML tag diff --git a/src/libespeak-ng/ssml.c b/src/libespeak-ng/ssml.c index 1bc849a7..de811d84 100644 --- a/src/libespeak-ng/ssml.c +++ b/src/libespeak-ng/ssml.c @@ -574,6 +574,11 @@ int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outbuf, con PARAM_STACK *sp; SSML_STACK *ssml_sp; + // don't process comments and xml declarations + if (wcsncmp(xml_buf, (wchar_t *) "!--", 3) == 0 || wcsncmp(xml_buf, (wchar_t *) "?xml", 4) == 0) { + return 0; + } + // these tags have no effect if they are self-closing, eg. static char ignore_if_self_closing[] = { 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0 };