Browse Source

code cleanup: move strncpy0 to common.c

master
Juho Hiltunen 2 years ago
parent
commit
b52d1f3afd

+ 6
- 0
src/libespeak-ng/common.c View File

@@ -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

+ 1
- 0
src/libespeak-ng/common.h View File

@@ -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
}

+ 1
- 2
src/libespeak-ng/compiledata.c View File

@@ -35,8 +35,7 @@
#include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.h>

#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

+ 2
- 1
src/libespeak-ng/compiledict.c View File

@@ -33,8 +33,9 @@
#include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.h>

#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...

+ 1
- 10
src/libespeak-ng/dictionary.c View File

@@ -32,7 +32,7 @@
#include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.h>

#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

+ 0
- 1
src/libespeak-ng/dictionary.h View File

@@ -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);

+ 1
- 1
src/libespeak-ng/error.c View File

@@ -27,7 +27,7 @@
#include <espeak-ng/espeak_ng.h>

#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,

+ 1
- 1
src/libespeak-ng/readclause.c View File

@@ -37,7 +37,7 @@
#include <ucd/ucd.h>

#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

+ 1
- 1
src/libespeak-ng/ssml.c View File

@@ -40,7 +40,7 @@
#include <ucd/ucd.h>

#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

+ 3
- 1
src/libespeak-ng/translateword.c View File

@@ -34,6 +34,8 @@
#include <espeak-ng/encoding.h>

#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);

+ 2
- 2
src/libespeak-ng/voices.c View File

@@ -39,8 +39,8 @@
#include <espeak-ng/encoding.h>

#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

Loading…
Cancel
Save