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

return statbuf.st_size; 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 #pragma GCC visibility pop

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

#include "espeak-ng/espeak_ng.h" #include "espeak-ng/espeak_ng.h"


extern ESPEAK_NG_API int GetFileLength(const char *filename); extern ESPEAK_NG_API int GetFileLength(const char *filename);
extern ESPEAK_NG_API void strncpy0(char *to, const char *from, int size);


#ifdef __cplusplus #ifdef __cplusplus
} }

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

#include <espeak-ng/speak_lib.h> #include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.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 "error.h" // for create_file_error_context
#include "mnemonics.h" // for LookupMnemName, MNEM_TAB #include "mnemonics.h" // for LookupMnemName, MNEM_TAB
#include "phoneme.h" // for PHONEME_TAB, PHONEME_TAB_LIST #include "phoneme.h" // for PHONEME_TAB, PHONEME_TAB_LIST

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

#include <espeak-ng/speak_lib.h> #include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.h> #include <espeak-ng/encoding.h>


#include "common.h" // for strncpy0
#include "compiledict.h" #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 "error.h" // for create_file_error_context
#include "mnemonics.h" // for LookupMnemName, MNEM_TAB #include "mnemonics.h" // for LookupMnemName, MNEM_TAB
#include "phoneme.h" // for PHONEME_TAB_LIST, phonSWITCH, phone... #include "phoneme.h" // for PHONEME_TAB_LIST, phonSWITCH, phone...

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

#include <espeak-ng/speak_lib.h> #include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.h> #include <espeak-ng/encoding.h>


#include "common.h" // for GetFileLength
#include "common.h" // for GetFileLength, strncpy0
#include "dictionary.h" #include "dictionary.h"
#include "numbers.h" // for LookupAccentedLetter, Look... #include "numbers.h" // for LookupAccentedLetter, Look...
#include "phoneme.h" // for PHONEME_TAB, phVOWEL, phon... #include "phoneme.h" // for PHONEME_TAB, phVOWEL, phon...
'a', 'a', 'a', 'b', 'o', 'c', 'd', 'd', 'e', 'e', 'e', 'e', 'e', 'e' '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) static int Reverse4Bytes(int word)
{ {
// reverse the order of bytes from little-endian to big-endian // reverse the order of bytes from little-endian to big-endian

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

{ {
#endif #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 LoadDictionary(Translator *tr, const char *name, int no_error);
int HashDictionary(const char *string); int HashDictionary(const char *string);
const char *EncodePhonemes(const char *p, char *outptr, int *bad_phoneme); const char *EncodePhonemes(const char *p, char *outptr, int *bad_phoneme);

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

#include <espeak-ng/espeak_ng.h> #include <espeak-ng/espeak_ng.h>


#include "error.h" #include "error.h"
#include "dictionary.h" // for strncpy0
#include "common.h" // for strncpy0


espeak_ng_STATUS espeak_ng_STATUS
create_file_error_context(espeak_ng_ERROR_CONTEXT *context, create_file_error_context(espeak_ng_ERROR_CONTEXT *context,

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

#include <ucd/ucd.h> #include <ucd/ucd.h>


#include "readclause.h" #include "readclause.h"
#include "common.h" // for GetFileLength
#include "common.h" // for GetFileLength, strncpy0
#include "config.h" // for HAVE_MKSTEMP #include "config.h" // for HAVE_MKSTEMP
#include "dictionary.h" // for LookupDictList, DecodePhonemes, Set... #include "dictionary.h" // for LookupDictList, DecodePhonemes, Set...
#include "error.h" // for create_file_error_context #include "error.h" // for create_file_error_context

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

#include <ucd/ucd.h> #include <ucd/ucd.h>


#include "ssml.h" #include "ssml.h"
#include "dictionary.h" // for strncpy0
#include "common.h" // for strncpy0
#include "mnemonics.h" // for LookupMnemName, MNEM_TAB, #include "mnemonics.h" // for LookupMnemName, MNEM_TAB,
#include "readclause.h" // for PARAM_STACK, param_stack, AddNameData #include "readclause.h" // for PARAM_STACK, param_stack, AddNameData
#include "soundicon.h" // for LoadSoundFile2 #include "soundicon.h" // for LoadSoundFile2

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

#include <espeak-ng/encoding.h> #include <espeak-ng/encoding.h>


#include "translate.h" #include "translate.h"
#include "translateword.h"
#include "common.h" // for strncpy0
#include "dictionary.h" // for TranslateRules, LookupDictList, Cha... #include "dictionary.h" // for TranslateRules, LookupDictList, Cha...
#include "numbers.h" // for SetSpellingStress, ... #include "numbers.h" // for SetSpellingStress, ...
#include "phoneme.h" // for phonSWITCH, PHONEME_TAB, phonPAUSE_... #include "phoneme.h" // for phonSWITCH, PHONEME_TAB, phonPAUSE_...
#include "synthdata.h" // for SelectPhonemeTable, LookupPhonemeTable #include "synthdata.h" // for SelectPhonemeTable, LookupPhonemeTable
#include "ucd/ucd.h" // for ucd_toupper #include "ucd/ucd.h" // for ucd_toupper
#include "voice.h" // for voice, voice_t #include "voice.h" // for voice, voice_t
#include "translateword.h"


static void addPluralSuffixes(int flags, Translator *tr, char last_char, char *word_phonemes); static void addPluralSuffixes(int flags, Translator *tr, char last_char, char *word_phonemes);
static int CheckDottedAbbrev(char *word1); static int CheckDottedAbbrev(char *word1);

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

#include <espeak-ng/encoding.h> #include <espeak-ng/encoding.h>


#include "voice.h" // for voice_t, DoVoiceChange, N_PEAKS #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 "mnemonics.h" // for LookupMnemName, MNEM_TAB
#include "phoneme.h" // for REPLACE_PHONEMES, n_replace_pho... #include "phoneme.h" // for REPLACE_PHONEMES, n_replace_pho...
#include "speech.h" // for PATHSEP #include "speech.h" // for PATHSEP

Loading…
Cancel
Save