diff --git a/src/libespeak-ng/common.c b/src/libespeak-ng/common.c index d8776d78..fdb376d5 100644 --- a/src/libespeak-ng/common.c +++ b/src/libespeak-ng/common.c @@ -51,4 +51,10 @@ int GetFileLength(const char *filename) return statbuf.st_size; } +void strncpy0(char *to, const char *from, int size) +{ + // strcpy with limit, ensures a zero terminator + strncpy(to, from, size); + to[size-1] = 0; +} #pragma GCC visibility pop diff --git a/src/libespeak-ng/common.h b/src/libespeak-ng/common.h index b011dd27..61846ce4 100644 --- a/src/libespeak-ng/common.h +++ b/src/libespeak-ng/common.h @@ -23,6 +23,7 @@ #include "espeak-ng/espeak_ng.h" extern ESPEAK_NG_API int GetFileLength(const char *filename); +extern ESPEAK_NG_API void strncpy0(char *to, const char *from, int size); #ifdef __cplusplus } diff --git a/src/libespeak-ng/compiledata.c b/src/libespeak-ng/compiledata.c index da1063ca..1fef7602 100644 --- a/src/libespeak-ng/compiledata.c +++ b/src/libespeak-ng/compiledata.c @@ -35,8 +35,7 @@ #include #include -#include "common.h" // for GetFileLength -#include "dictionary.h" // for strncpy0 +#include "common.h" // for GetFileLength, strncpy0 #include "error.h" // for create_file_error_context #include "mnemonics.h" // for LookupMnemName, MNEM_TAB #include "phoneme.h" // for PHONEME_TAB, PHONEME_TAB_LIST diff --git a/src/libespeak-ng/compiledict.c b/src/libespeak-ng/compiledict.c index cfe31c69..e830859f 100644 --- a/src/libespeak-ng/compiledict.c +++ b/src/libespeak-ng/compiledict.c @@ -33,8 +33,9 @@ #include #include +#include "common.h" // for strncpy0 #include "compiledict.h" -#include "dictionary.h" // for EncodePhonemes, strncpy0, HashDicti... +#include "dictionary.h" // for EncodePhonemes, HashDicti... #include "error.h" // for create_file_error_context #include "mnemonics.h" // for LookupMnemName, MNEM_TAB #include "phoneme.h" // for PHONEME_TAB_LIST, phonSWITCH, phone... diff --git a/src/libespeak-ng/dictionary.c b/src/libespeak-ng/dictionary.c index 2dbcd451..858d5066 100644 --- a/src/libespeak-ng/dictionary.c +++ b/src/libespeak-ng/dictionary.c @@ -32,7 +32,7 @@ #include #include -#include "common.h" // for GetFileLength +#include "common.h" // for GetFileLength, strncpy0 #include "dictionary.h" #include "numbers.h" // for LookupAccentedLetter, Look... #include "phoneme.h" // for PHONEME_TAB, phVOWEL, phon... @@ -91,15 +91,6 @@ static unsigned char remove_accent[N_REMOVE_ACCENT] = { 'a', 'a', 'a', 'b', 'o', 'c', 'd', 'd', 'e', 'e', 'e', 'e', 'e', 'e' }; -#pragma GCC visibility push(default) -void strncpy0(char *to, const char *from, int size) -{ - // strcpy with limit, ensures a zero terminator - strncpy(to, from, size); - to[size-1] = 0; -} -#pragma GCC visibility pop - static int Reverse4Bytes(int word) { // reverse the order of bytes from little-endian to big-endian diff --git a/src/libespeak-ng/dictionary.h b/src/libespeak-ng/dictionary.h index ecdfec07..fb9a8ff1 100644 --- a/src/libespeak-ng/dictionary.h +++ b/src/libespeak-ng/dictionary.h @@ -31,7 +31,6 @@ extern "C" { #endif -extern ESPEAK_NG_API void strncpy0(char *to, const char *from, int size); int LoadDictionary(Translator *tr, const char *name, int no_error); int HashDictionary(const char *string); const char *EncodePhonemes(const char *p, char *outptr, int *bad_phoneme); diff --git a/src/libespeak-ng/error.c b/src/libespeak-ng/error.c index b816c2aa..9e1c2cdc 100644 --- a/src/libespeak-ng/error.c +++ b/src/libespeak-ng/error.c @@ -27,7 +27,7 @@ #include #include "error.h" -#include "dictionary.h" // for strncpy0 +#include "common.h" // for strncpy0 espeak_ng_STATUS create_file_error_context(espeak_ng_ERROR_CONTEXT *context, diff --git a/src/libespeak-ng/readclause.c b/src/libespeak-ng/readclause.c index 28db89f8..b6147033 100644 --- a/src/libespeak-ng/readclause.c +++ b/src/libespeak-ng/readclause.c @@ -37,7 +37,7 @@ #include #include "readclause.h" -#include "common.h" // for GetFileLength +#include "common.h" // for GetFileLength, strncpy0 #include "config.h" // for HAVE_MKSTEMP #include "dictionary.h" // for LookupDictList, DecodePhonemes, Set... #include "error.h" // for create_file_error_context diff --git a/src/libespeak-ng/ssml.c b/src/libespeak-ng/ssml.c index c6c2bd15..ef6236d7 100644 --- a/src/libespeak-ng/ssml.c +++ b/src/libespeak-ng/ssml.c @@ -40,7 +40,7 @@ #include #include "ssml.h" -#include "dictionary.h" // for strncpy0 +#include "common.h" // for strncpy0 #include "mnemonics.h" // for LookupMnemName, MNEM_TAB, #include "readclause.h" // for PARAM_STACK, param_stack, AddNameData #include "soundicon.h" // for LoadSoundFile2 diff --git a/src/libespeak-ng/translateword.c b/src/libespeak-ng/translateword.c index 23fac5ba..98a7e111 100644 --- a/src/libespeak-ng/translateword.c +++ b/src/libespeak-ng/translateword.c @@ -34,6 +34,8 @@ #include #include "translate.h" +#include "translateword.h" +#include "common.h" // for strncpy0 #include "dictionary.h" // for TranslateRules, LookupDictList, Cha... #include "numbers.h" // for SetSpellingStress, ... #include "phoneme.h" // for phonSWITCH, PHONEME_TAB, phonPAUSE_... @@ -41,7 +43,7 @@ #include "synthdata.h" // for SelectPhonemeTable, LookupPhonemeTable #include "ucd/ucd.h" // for ucd_toupper #include "voice.h" // for voice, voice_t -#include "translateword.h" + static void addPluralSuffixes(int flags, Translator *tr, char last_char, char *word_phonemes); static int CheckDottedAbbrev(char *word1); diff --git a/src/libespeak-ng/voices.c b/src/libespeak-ng/voices.c index 151ad585..4627e92e 100644 --- a/src/libespeak-ng/voices.c +++ b/src/libespeak-ng/voices.c @@ -39,8 +39,8 @@ #include #include "voice.h" // for voice_t, DoVoiceChange, N_PEAKS -#include "common.h" // for GetFileLength -#include "dictionary.h" // for strncpy0, LoadDictionary +#include "common.h" // for GetFileLength, strncpy0 +#include "dictionary.h" // for LoadDictionary #include "mnemonics.h" // for LookupMnemName, MNEM_TAB #include "phoneme.h" // for REPLACE_PHONEMES, n_replace_pho... #include "speech.h" // for PATHSEP