From 45f25b5564cf8ac9819acfa5cdb6e103b907d7ba Mon Sep 17 00:00:00 2001 From: Cameron Wong Date: Thu, 29 Sep 2022 09:36:31 +0800 Subject: [PATCH] Fix dictionary_skipwords bug. It should be injected when re-structing method TranslateWord3. --- src/libespeak-ng/translate.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libespeak-ng/translate.c b/src/libespeak-ng/translate.c index 8759b48c..01f89002 100644 --- a/src/libespeak-ng/translate.c +++ b/src/libespeak-ng/translate.c @@ -164,6 +164,10 @@ int TranslateWord(Translator *tr, char *word_start, WORD_TAB *wtab, char *word_o wtab->flags &= ~FLAG_FIRST_UPPER; } + // dictionary_skipwords is a global variable and TranslateWord3 will reset it to 0 at the beginning. + // However, dictionary_skipwords value is still needed outside this scope. + // So we backup and restore it at the end of this scope. + int skipwords = dictionary_skipwords; TranslateWord3(tr, word_out, wtab, NULL, &any_stressed_words, current_alphabet, word_phonemes, sizeof(word_phonemes)); int n; @@ -182,6 +186,7 @@ int TranslateWord(Translator *tr, char *word_start, WORD_TAB *wtab, char *word_o while (!isspace(*word_out)) ++word_out; while (isspace(*word_out)) ++word_out; } + dictionary_skipwords = skipwords; } // If the list file contains a text replacement to another