mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-19 10:58:30 +00:00
Constify tables
So they are protected from overflows, and shared between processes
This commit is contained in:
@@ -598,7 +598,7 @@ static unsigned int StringToWord(const char *string)
|
||||
return word;
|
||||
}
|
||||
|
||||
static MNEM_TAB reserved_phonemes[] = {
|
||||
static const MNEM_TAB reserved_phonemes[] = {
|
||||
{ "_\001", phonCONTROL }, // NOT USED
|
||||
{ "%", phonSTRESS_U },
|
||||
{ "%%", phonSTRESS_D },
|
||||
@@ -641,7 +641,7 @@ static void ReservePhCodes()
|
||||
// Reserve phoneme codes which have fixed numbers so that they can be
|
||||
// referred to from the program code.
|
||||
unsigned int word;
|
||||
MNEM_TAB *p;
|
||||
const MNEM_TAB *p;
|
||||
|
||||
p = reserved_phonemes;
|
||||
while (p->mnem != NULL) {
|
||||
@@ -2671,7 +2671,7 @@ static const TUNE default_tune = {
|
||||
|
||||
#define N_TUNE_NAMES 100
|
||||
|
||||
MNEM_TAB envelope_names[] = {
|
||||
static const MNEM_TAB envelope_names[] = {
|
||||
{ "fall", 0 },
|
||||
{ "rise", 2 },
|
||||
{ "fall-rise", 4 },
|
||||
|
||||
@@ -64,7 +64,7 @@ static char *hash_chains[N_HASH_DICT];
|
||||
|
||||
static char letterGroupsDefined[N_LETTER_GROUPS];
|
||||
|
||||
MNEM_TAB mnem_rules[] = {
|
||||
static const MNEM_TAB mnem_rules[] = {
|
||||
{ "unpr", DOLLAR_UNPR },
|
||||
{ "noprefix", DOLLAR_NOPREFIX }, // rule fails if a prefix has been removed
|
||||
{ "list", DOLLAR_LIST }, // a pronunciation is given in the *_list file
|
||||
@@ -88,7 +88,7 @@ MNEM_TAB mnem_rules[] = {
|
||||
{ NULL, -1 }
|
||||
};
|
||||
|
||||
MNEM_TAB mnem_flags[] = {
|
||||
static const MNEM_TAB mnem_flags[] = {
|
||||
// these in the first group put a value in bits0-3 of dictionary_flags
|
||||
{ "$1", 0x41 }, // stress on 1st syllable
|
||||
{ "$2", 0x42 }, // stress on 2nd syllable
|
||||
@@ -779,7 +779,7 @@ static void copy_rule_string(char *string, int *state_out)
|
||||
bool literal;
|
||||
bool hexdigit_input = false;
|
||||
int state = *state_out;
|
||||
MNEM_TAB *mr;
|
||||
const MNEM_TAB *mr;
|
||||
|
||||
if (string[0] == 0) return;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "translate.h" // for LEADING_2_BITS, UTF8_TAIL_BITS
|
||||
|
||||
// http://www.iana.org/assignments/character-sets/character-sets.xhtml
|
||||
MNEM_TAB mnem_encoding[] = {
|
||||
static const MNEM_TAB mnem_encoding[] = {
|
||||
{ "ANSI_X3.4-1968", ESPEAKNG_ENCODING_US_ASCII },
|
||||
{ "ANSI_X3.4-1986", ESPEAKNG_ENCODING_US_ASCII },
|
||||
{ "ASMO-708", ESPEAKNG_ENCODING_ISO_8859_6 },
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "mnemonics.h" // for MNEM_TAB, LookupMnem, LookupMnemName
|
||||
|
||||
int LookupMnem(MNEM_TAB *table, const char *string)
|
||||
int LookupMnem(const MNEM_TAB *table, const char *string)
|
||||
{
|
||||
while (table->mnem != NULL) {
|
||||
if (string && strcmp(string, table->mnem) == 0)
|
||||
@@ -35,7 +35,7 @@ int LookupMnem(MNEM_TAB *table, const char *string)
|
||||
return table->value;
|
||||
}
|
||||
|
||||
const char *LookupMnemName(MNEM_TAB *table, const int value)
|
||||
const char *LookupMnemName(const MNEM_TAB *table, const int value)
|
||||
{
|
||||
while (table->mnem != NULL) {
|
||||
if (table->value == value)
|
||||
|
||||
@@ -30,8 +30,8 @@ typedef struct {
|
||||
const char *mnem;
|
||||
int value;
|
||||
} MNEM_TAB;
|
||||
int LookupMnem(MNEM_TAB *table, const char *string);
|
||||
const char *LookupMnemName(MNEM_TAB *table, const int value);
|
||||
int LookupMnem(const MNEM_TAB *table, const char *string);
|
||||
const char *LookupMnemName(const MNEM_TAB *table, const int value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
short int sin_tab[2048] = {
|
||||
const short int sin_tab[2048] = {
|
||||
0, -25, -50, -75, -100, -125, -150, -175,
|
||||
-201, -226, -251, -276, -301, -326, -351, -376,
|
||||
-401, -427, -452, -477, -502, -527, -552, -577,
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
#include "translate.h" // for CTRL_EMBEDDED, IsDigit09, utf8_out
|
||||
#include "voice.h" // for SelectVoice, SelectVoiceByName
|
||||
|
||||
static MNEM_TAB ssmltags[] = {
|
||||
static const MNEM_TAB ssmltags[] = {
|
||||
{ "speak", SSML_SPEAK },
|
||||
{ "voice", SSML_VOICE },
|
||||
{ "prosody", SSML_PROSODY },
|
||||
@@ -460,7 +460,7 @@ static void PopParamStack(int tag_type, char *outbuf, int *outix, int *n_param_s
|
||||
static int ReplaceKeyName(char *outbuf, int index, int *outix)
|
||||
{
|
||||
// Replace some key-names by single characters, so they can be pronounced in different languages
|
||||
static MNEM_TAB keynames[] = {
|
||||
static const MNEM_TAB keynames[] = {
|
||||
{ "space ", 0xe020 },
|
||||
{ "tab ", 0xe009 },
|
||||
{ "underscore ", 0xe05f },
|
||||
@@ -951,7 +951,7 @@ int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outbuf, con
|
||||
return 0;
|
||||
}
|
||||
|
||||
static MNEM_TAB xml_entity_mnemonics[] = {
|
||||
static const MNEM_TAB xml_entity_mnemonics[] = {
|
||||
{ "gt", '>' },
|
||||
{ "lt", 0xe000 + '<' }, // private usage area, to avoid confusion with XML tag
|
||||
{ "amp", '&' },
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
#include "translate.h" // for LANGUAGE_OPTIONS, DeleteTranslator
|
||||
#include "wavegen.h" // for InitBreath
|
||||
|
||||
MNEM_TAB genders[] = {
|
||||
static const MNEM_TAB genders[] = {
|
||||
{ "male", ENGENDER_MALE },
|
||||
{ "female", ENGENDER_FEMALE },
|
||||
{ NULL, ENGENDER_MALE }
|
||||
@@ -115,7 +115,7 @@ enum {
|
||||
V_CONSONANTS
|
||||
};
|
||||
|
||||
static MNEM_TAB keyword_tab[] = {
|
||||
static const MNEM_TAB keyword_tab[] = {
|
||||
{ "name", V_NAME },
|
||||
{ "language", V_LANGUAGE },
|
||||
{ "gender", V_GENDER },
|
||||
@@ -480,7 +480,7 @@ static int Read8Numbers(char *data_in, int *data)
|
||||
&data[0], &data[1], &data[2], &data[3], &data[4], &data[5], &data[6], &data[7]);
|
||||
}
|
||||
|
||||
static void ReadNumbers(char *p, int *flags, int maxValue, MNEM_TAB *keyword_tab, int key) {
|
||||
static void ReadNumbers(char *p, int *flags, int maxValue, const MNEM_TAB *keyword_tab, int key) {
|
||||
// read a list of numbers from string p
|
||||
// store them as flags in *flags
|
||||
// the meaning of the numbers is bit ordinals, not integer values
|
||||
@@ -500,7 +500,7 @@ static void ReadNumbers(char *p, int *flags, int maxValue, MNEM_TAB *keyword_ta
|
||||
}
|
||||
}
|
||||
|
||||
static int CheckTranslator(Translator *tr, MNEM_TAB *keyword_tab, int key)
|
||||
static int CheckTranslator(Translator *tr, const MNEM_TAB *keyword_tab, int key)
|
||||
{
|
||||
// Return 0 if translator is set.
|
||||
// Return 1 and print an error message for specified key if not
|
||||
|
||||
Reference in New Issue
Block a user