Browse Source

Fix missing checks for EOF

master
Samuel Thibault 2 years ago
parent
commit
9decedb8c2
1 changed files with 6 additions and 6 deletions
  1. 6
    6
      src/libespeak-ng/readclause.c

+ 6
- 6
src/libespeak-ng/readclause.c View File

@@ -339,7 +339,7 @@ static int AnnouncePunctuation(Translator *tr, int c1, int *c2_ptr, char *output

if ((*bufix == 0) || (end_clause == 0) || (tr->langopts.param[LOPT_ANNOUNCE_PUNCT] & 2)) {
punct_count = 1;
while ((c2 == c1) && (c1 != '<')) { // don't eat extra '<', it can miss XML tags
while (!Eof() && (c2 == c1) && (c1 != '<')) { // don't eat extra '<', it can miss XML tags
punct_count++;
c2 = GetC();
}
@@ -653,7 +653,7 @@ int ReadClause(Translator *tr, char *buf, short *charix, int *charix_top, int n_
// an embedded command. If it's a voice change, end the clause
if (c2 == 'V') {
buf[ix++] = 0; // end the clause at this point
while (!iswspace(c1 = GetC()) && !Eof() && (ix < (n_buf-1)))
while (!Eof() && !iswspace(c1 = GetC()) && (ix < (n_buf-1)))
buf[ix++] = c1; // add voice name to end of buffer, after the text
buf[ix++] = 0;
return CLAUSE_VOICE;
@@ -663,7 +663,7 @@ int ReadClause(Translator *tr, char *buf, short *charix, int *charix_top, int n_
strcpy(&buf[ix], " ");
ix += 3;

if ((c2 = GetC()) == '0')
if (!Eof() && (c2 = GetC()) == '0')
option_punctuation = 0;
else {
option_punctuation = 1;
@@ -671,7 +671,7 @@ int ReadClause(Translator *tr, char *buf, short *charix, int *charix_top, int n_
if (c2 != '1') {
// a list of punctuation characters to be spoken, terminated by space
j = 0;
while (!iswspace(c2) && !Eof()) {
while (!Eof() && !iswspace(c2)) {
option_punctlist[j++] = c2;
c2 = GetC();
buf[ix++] = ' ';
@@ -797,7 +797,7 @@ int ReadClause(Translator *tr, char *buf, short *charix, int *charix_top, int n_
}

if ((c1 == '.') && (c2 == '.')) {
while ((c_next = GetC()) == '.') {
while (!Eof() && (c_next = GetC()) == '.') {
// 3 or more dots, replace by elipsis
c1 = 0x2026;
c2 = ' ';
@@ -814,7 +814,7 @@ int ReadClause(Translator *tr, char *buf, short *charix, int *charix_top, int n_
// Handling of sequences of ? and ! like ??!?, !!??!, ?!! etc
// Use only first char as determinant
if(punct_data & (CLAUSE_QUESTION | CLAUSE_EXCLAMATION)) {
while(clause_type_from_codepoint(c2) & (CLAUSE_QUESTION | CLAUSE_EXCLAMATION)) {
while(!Eof() && clause_type_from_codepoint(c2) & (CLAUSE_QUESTION | CLAUSE_EXCLAMATION)) {
c_next = GetC();
c2 = c_next;
}

Loading…
Cancel
Save