Browse Source

Add unquoted attributes support in SSML parser (#1515)

Also check for empty skip_marker name in SSML_MARK.

Fixes #975
master
Alexander Epaneshnikov 2 years ago
parent
commit
1a739d6c24
No account linked to committer's email address
1 changed files with 10 additions and 3 deletions
  1. 10
    3
      src/libespeak-ng/ssml.c

+ 10
- 3
src/libespeak-ng/ssml.c View File

int ix = 0; int ix = 0;


if (pw != NULL) { if (pw != NULL) {
wchar_t quote = pw[-1];
if ((quote != '"') && (quote != '\'')) quote = 0;

unsigned int c; unsigned int c;
int prev_c = 0; int prev_c = 0;
while ((ix < (len-4)) && ((c = *pw++) != 0)) { while ((ix < (len-4)) && ((c = *pw++) != 0)) {
if ((c == '"') && (prev_c != '\\'))
if ((quote == 0) && (isspace(c) || (c == '/')))
break;
if ((quote != 0) && (c == quote) && (prev_c != '\\'))
break; // " indicates end of attribute, unless preceded by backstroke break; // " indicates end of attribute, unless preceded by backstroke


int n = utf8_out(c, &buf[ix]); int n = utf8_out(c, &buf[ix]);
while (iswspace(*pw)) pw++; while (iswspace(*pw)) pw++;
if ((*pw == '"') || (*pw == '\'')) // allow single-quotes ? if ((*pw == '"') || (*pw == '\'')) // allow single-quotes ?
return pw+1; return pw+1;
else
else if (iswspace(*pw) || (*pw == '/')) // end of attribute
return empty; return empty;
else
return pw;
} }
} }
pw++; pw++;
// add name to circular buffer of marker names // add name to circular buffer of marker names
attrcopy_utf8(buf, attr1, sizeof(buf)); attrcopy_utf8(buf, attr1, sizeof(buf));


if (strcmp(skip_marker, buf) == 0) {
if ((buf[0] != 0) && (strcmp(skip_marker, buf) == 0)) {
// This is the marker we are waiting for before starting to speak // This is the marker we are waiting for before starting to speak
*clear_skipping_text = true; *clear_skipping_text = true;
skip_marker[0] = 0; skip_marker[0] = 0;

Loading…
Cancel
Save