Browse Source

Fix: Word events had a bad text index if the word starts with a non-ascii character.

git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@177 d46cf337-b52f-0410-862d-fd96e6ae7743
master
jonsd 17 years ago
parent
commit
f4ea533d83
3 changed files with 8 additions and 8 deletions
  1. 3
    3
      src/readclause.cpp
  2. 4
    4
      src/translate.cpp
  3. 1
    1
      src/translate.h

+ 3
- 3
src/readclause.cpp View File

{NULL,-1}}; {NULL,-1}};




int Translator::ReadClause(FILE *f_in, char *buf, unsigned short *charix, int n_buf)
{//=================================================================================
int Translator::ReadClause(FILE *f_in, char *buf, short *charix, int n_buf)
{//========================================================================
/* Find the end of the current clause. /* Find the end of the current clause.
Write the clause into buf Write the clause into buf


{ {
charix[ix] = count_characters - clause_start_char; charix[ix] = count_characters - clause_start_char;
while(j < ix) while(j < ix)
charix[j++] = 0xffff; // subsequent bytes of a multibyte character
charix[j++] = -1; // subsequent bytes of a multibyte character
} }


if(((ix > (n_buf-20)) && !IsAlpha(c1) && !iswdigit(c1)) || (ix >= (n_buf-2))) if(((ix > (n_buf-20)) && !IsAlpha(c1) && !iswdigit(c1)) || (ix >= (n_buf-2)))

+ 4
- 4
src/translate.cpp View File

int j, k; int j, k;
int n_digits; int n_digits;


unsigned short charix[N_TR_SOURCE+1];
short charix[N_TR_SOURCE+1];


WORD_TAB words[N_CLAUSE_WORDS]; WORD_TAB words[N_CLAUSE_WORDS];
int word_count=0; // index into words int word_count=0; // index into words
while(charix[j] != 0) while(charix[j] != 0)
{ {
// count the number of characters (excluding multibyte continuation bytes) // count the number of characters (excluding multibyte continuation bytes)
if(charix[j++] != 0xffff)
if(charix[j++] != -1)
k++; k++;
} }
words[0].length = k; words[0].length = k;
words[word_count].start = ix; words[word_count].start = ix;
words[word_count].flags = 0; words[word_count].flags = 0;


for(j=source_index; charix[j] == 0; j++); // skip blanks
for(j=source_index; charix[j] <= 0; j++); // skip blanks
words[word_count].sourceix = charix[j]; words[word_count].sourceix = charix[j];
k = 0; k = 0;
while(charix[j] != 0) while(charix[j] != 0)
{ {
// count the number of characters (excluding multibyte continuation bytes) // count the number of characters (excluding multibyte continuation bytes)
if(charix[j++] != 0xffff)
if(charix[j++] != -1)
k++; k++;
} }
words[word_count].length = k; words[word_count].length = k;

+ 1
- 1
src/translate.h View File

void MakePhonemeList(int post_pause, int new_sentence); void MakePhonemeList(int post_pause, int new_sentence);
int SubstitutePhonemes(PHONEME_LIST2 *plist_out); int SubstitutePhonemes(PHONEME_LIST2 *plist_out);


int ReadClause(FILE *f_in, char *buf, unsigned short *charix, int n_buf);
int ReadClause(FILE *f_in, char *buf, short *charix, int n_buf);
int AnnouncePunctuation(int c1, int c2, char *buf, int ix); int AnnouncePunctuation(int c1, int c2, char *buf, int ix);


const char *LookupDict2(const char *word, const char *word2, char *phonetic, unsigned int *flags, int end_flags, WORD_TAB *wtab); const char *LookupDict2(const char *word, const char *word2, char *phonetic, unsigned int *flags, int end_flags, WORD_TAB *wtab);

Loading…
Cancel
Save