From 89b2a55ea414dfcb9f93a9e8c6fdeac2a19292f5 Mon Sep 17 00:00:00 2001 From: Yury Popov Date: Fri, 18 Nov 2022 20:01:51 +0300 Subject: [PATCH] code cleanup: remove static from WordToString --- src/libespeak-ng/compiledata.c | 3 ++- src/libespeak-ng/synth_mbrola.c | 7 ++++--- src/libespeak-ng/synthdata.c | 3 ++- src/libespeak-ng/synthesize.c | 5 +---- src/libespeak-ng/synthesize.h | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libespeak-ng/compiledata.c b/src/libespeak-ng/compiledata.c index 561086f0..0d26cab5 100644 --- a/src/libespeak-ng/compiledata.c +++ b/src/libespeak-ng/compiledata.c @@ -2197,6 +2197,7 @@ static void WritePhonemeTables(CompileContext *ctx) static void EndPhonemeTable(CompileContext *ctx) { int ix; + char buf[5]; if (ctx->n_phoneme_tabs == 0) return; @@ -2205,7 +2206,7 @@ static void EndPhonemeTable(CompileContext *ctx) for (ix = 0; ix < ctx->n_phcodes; ix++) { if (ctx->phoneme_tab2[ix].type == phINVALID) { error(ctx, "Phoneme [%s] not declared, referenced at line %d", - WordToString(ctx->phoneme_tab2[ix].mnemonic), (int)(ctx->phoneme_tab2[ix].program)); + WordToString(buf, ctx->phoneme_tab2[ix].mnemonic), (int)(ctx->phoneme_tab2[ix].program)); ctx->error_count++; ctx->phoneme_tab2[ix].type = 0; // prevent the error message repeating } diff --git a/src/libespeak-ng/synth_mbrola.c b/src/libespeak-ng/synth_mbrola.c index 651efa2f..a234f13f 100644 --- a/src/libespeak-ng/synth_mbrola.c +++ b/src/libespeak-ng/synth_mbrola.c @@ -350,6 +350,7 @@ int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, bool resume, FILE *f_mb const char *final_pitch; char *ptr; char mbr_buf[120]; + char phbuf[5]; static int phix; static int embedded_ix; @@ -405,7 +406,7 @@ int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, bool resume, FILE *f_mb DoPhonemeMarker(espeakEVENT_PHONEME, (p->sourceix & 0x7ff) + clause_start_char, 0, phoneme_name); } - ptr += sprintf(ptr, "%s\t", WordToString(name)); + ptr += sprintf(ptr, "%s\t", WordToString(phbuf, name)); if (name2 == '_') { // add a pause after this phoneme @@ -438,7 +439,7 @@ int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, bool resume, FILE *f_mb ptr += sprintf(ptr, "%d\t%s", len1, pitch); pitch = WritePitch(p->env, p->pitch1, p->pitch2, -len_percent, 0); - ptr += sprintf(ptr, "%s\t%d\t%s", WordToString(name2), len-len1, pitch); + ptr += sprintf(ptr, "%s\t%d\t%s", WordToString(phbuf, name2), len-len1, pitch); } done = true; break; @@ -490,7 +491,7 @@ int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, bool resume, FILE *f_mb if (!done) { if (name2 != 0) { len1 = (len * len_percent)/100; - ptr += sprintf(ptr, "%d\n%s\t", len1, WordToString(name2)); + ptr += sprintf(ptr, "%d\n%s\t", len1, WordToString(phbuf, name2)); len -= len1; } ptr += sprintf(ptr, "%d%s\n", len, final_pitch); diff --git a/src/libespeak-ng/synthdata.c b/src/libespeak-ng/synthdata.c index 8d40149b..5dc51fba 100644 --- a/src/libespeak-ng/synthdata.c +++ b/src/libespeak-ng/synthdata.c @@ -391,7 +391,8 @@ int SelectPhonemeTableName(const char *name) static void InvalidInstn(PHONEME_TAB *ph, int instn) { - fprintf(stderr, "Invalid instruction %.4x for phoneme '%s'\n", instn, WordToString(ph->mnemonic)); + char buf[5]; + fprintf(stderr, "Invalid instruction %.4x for phoneme '%s'\n", instn, WordToString(buf, ph->mnemonic)); } static bool StressCondition(Translator *tr, PHONEME_LIST *plist, int condition, int control) diff --git a/src/libespeak-ng/synthesize.c b/src/libespeak-ng/synthesize.c index f088fc92..ebcddb7e 100644 --- a/src/libespeak-ng/synthesize.c +++ b/src/libespeak-ng/synthesize.c @@ -72,13 +72,10 @@ static voice_t *new_voice = NULL; #define RMS_START 28 // 28 #define VOWEL_FRONT_LENGTH 50 -const char *WordToString(unsigned int word) +const char *WordToString(char buf[5], unsigned int word) { // Convert a phoneme mnemonic word into a string int ix; - static char buf[5]; - - MAKE_MEM_UNDEFINED(&buf, sizeof(buf)); for (ix = 0; ix < 4; ix++) buf[ix] = word >> (ix*8); diff --git a/src/libespeak-ng/synthesize.h b/src/libespeak-ng/synthesize.h index fa96b7c9..15100ed5 100644 --- a/src/libespeak-ng/synthesize.h +++ b/src/libespeak-ng/synthesize.h @@ -463,7 +463,7 @@ void DoPhonemeMarker(int type, int char_posn, int length, char *name); int DoSample3(PHONEME_DATA *phdata, int length_mod, int amp); int DoSpect2(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params, PHONEME_LIST *plist, int modulation); int PauseLength(int pause, int control); -const char *WordToString(unsigned int word); +const char *WordToString(char buf[5], unsigned int word); #ifdef __cplusplus }