diff --git a/src/libespeak-ng/dictionary.c b/src/libespeak-ng/dictionary.c index 14776904..1f835dbc 100644 --- a/src/libespeak-ng/dictionary.c +++ b/src/libespeak-ng/dictionary.c @@ -2084,6 +2084,7 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c int ix; unsigned int digit_count = 0; char *p; + char word_buf[5]; const ALPHABET *alphabet; int dict_flags0 = 0; MatchRecord match1 = { 0 }; @@ -2240,12 +2241,12 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c if (((alphabet = AlphabetFromChar(letter)) != NULL) && (alphabet->offset != tr->letter_bits_offset)) { if (tr->langopts.alt_alphabet == alphabet->offset) { - sprintf(phonemes, "%c%s", phonSWITCH, WordToString2(tr->langopts.alt_alphabet_lang)); + sprintf(phonemes, "%c%s", phonSWITCH, WordToString2(word_buf, tr->langopts.alt_alphabet_lang)); return 0; } if (alphabet->flags & AL_WORDS) { // switch to the nominated language for this alphabet - sprintf(phonemes, "%c%s", phonSWITCH, WordToString2(alphabet->language)); + sprintf(phonemes, "%c%s", phonSWITCH, WordToString2(word_buf, alphabet->language)); return 0; } } diff --git a/src/libespeak-ng/readclause.c b/src/libespeak-ng/readclause.c index 9b98b618..d287e028 100644 --- a/src/libespeak-ng/readclause.c +++ b/src/libespeak-ng/readclause.c @@ -167,15 +167,12 @@ static void UngetC(int c) ungot_char = c; } -const char *WordToString2(unsigned int word) +const char *WordToString2(char buf[5], unsigned int word) { // Convert a language mnemonic word into a string int ix; - static char buf[5]; char *p; - MAKE_MEM_UNDEFINED(&buf, sizeof(buf)); - p = buf; for (ix = 3; ix >= 0; ix--) { if ((*p = word >> (ix*8)) != 0) @@ -199,7 +196,7 @@ static const char *LookupSpecial(Translator *tr, const char *string, char *text_ return NULL; } -static const char *LookupCharName(Translator *tr, int c, bool only) +static const char *LookupCharName(char buf[60], Translator *tr, int c, bool only) { // Find the phoneme string (in ascii) to speak the name of character c // Used for punctuation characters and symbols @@ -210,9 +207,6 @@ static const char *LookupCharName(Translator *tr, int c, bool only) char phonemes[60]; const char *lang_name = NULL; char *string; - static char buf[60]; - - MAKE_MEM_UNDEFINED(&buf, sizeof(buf)); buf[0] = 0; flags[0] = 0; @@ -284,6 +278,7 @@ static int AnnouncePunctuation(Translator *tr, int c1, int *c2_ptr, char *output int bufix1; char buf[200]; char ph_buf[30]; + char cn_buf[60]; c2 = *c2_ptr; buf[0] = 0; @@ -298,7 +293,7 @@ static int AnnouncePunctuation(Translator *tr, int c1, int *c2_ptr, char *output punctname = ph_buf; // use word for 'period' instead of 'dot' } if (punctname == NULL) - punctname = LookupCharName(tr, c1, false); + punctname = LookupCharName(cn_buf, tr, c1, false); if (punctname == NULL) return -1; @@ -833,7 +828,8 @@ int ReadClause(Translator *tr, char *buf, short *charix, int *charix_top, int n_ char *p2; p2 = &buf[ix]; - sprintf(p2, "%s", LookupCharName(tr, c1, true)); + char cn_buf[60]; + sprintf(p2, "%s", LookupCharName(cn_buf, tr, c1, true)); if (p2[0] != 0) { ix += strlen(p2); announced_punctuation = c1; @@ -1020,6 +1016,7 @@ static void DecodeWithPhonemeMode(char *buf, char *phonemes, Translator *tr, Tra } else { SetWordStress(tr2, phonemes, flags, -1, 0); DecodePhonemes(phonemes, phonemes2); - sprintf(buf, "[\002_^_%s %s _^_%s]]", ESPEAKNG_DEFAULT_VOICE, phonemes2, WordToString2(tr->translator_name)); + char wbuf[5]; + sprintf(buf, "[\002_^_%s %s _^_%s]]", ESPEAKNG_DEFAULT_VOICE, phonemes2, WordToString2(wbuf, tr->translator_name)); } -} \ No newline at end of file +} diff --git a/src/libespeak-ng/readclause.h b/src/libespeak-ng/readclause.h index e55235ea..cd5cd4b0 100644 --- a/src/libespeak-ng/readclause.h +++ b/src/libespeak-ng/readclause.h @@ -36,7 +36,7 @@ extern PARAM_STACK param_stack[]; int clause_type_from_codepoint(uint32_t c); int Eof(void); -const char *WordToString2(unsigned int word); +const char *WordToString2(char buf[5], unsigned int word); int AddNameData(const char *name, int wide); int ReadClause(Translator *tr, diff --git a/src/libespeak-ng/translateword.c b/src/libespeak-ng/translateword.c index 303c2183..9382bca4 100644 --- a/src/libespeak-ng/translateword.c +++ b/src/libespeak-ng/translateword.c @@ -918,7 +918,8 @@ static int TranslateLetter(Translator *tr, char *word, char *phonemes, int contr char hangul_buf[12]; // speak in the language for this alphabet (or English) - ph_buf[2] = SetTranslator3(WordToString2(language)); + char word_buf[5]; + ph_buf[2] = SetTranslator3(WordToString2(word_buf, language)); if (translator3 != NULL) { int code; diff --git a/src/libespeak-ng/voices.c b/src/libespeak-ng/voices.c index c71b4bb6..b6cf88bb 100644 --- a/src/libespeak-ng/voices.c +++ b/src/libespeak-ng/voices.c @@ -1072,9 +1072,7 @@ char const *SelectVoice(espeak_VOICE *voice_select, int *found) if ((voice_select2.languages == NULL) || (voice_select2.languages[0] == 0)) { // no language is specified. Get language from the named voice - static char buf[60]; - - MAKE_MEM_UNDEFINED(&buf, sizeof(buf)); + char buf[60]; if (voice_select2.name == NULL) { if ((voice_select2.name = voice_select2.identifier) == NULL)