Browse Source

Constify tables

So they are protected from overflows, and shared between processes
master
Samuel Thibault 3 years ago
parent
commit
15804e57a2

+ 3
- 3
src/libespeak-ng/compiledata.c View File

return word; return word;
} }


static MNEM_TAB reserved_phonemes[] = {
static const MNEM_TAB reserved_phonemes[] = {
{ "_\001", phonCONTROL }, // NOT USED { "_\001", phonCONTROL }, // NOT USED
{ "%", phonSTRESS_U }, { "%", phonSTRESS_U },
{ "%%", phonSTRESS_D }, { "%%", phonSTRESS_D },
// Reserve phoneme codes which have fixed numbers so that they can be // Reserve phoneme codes which have fixed numbers so that they can be
// referred to from the program code. // referred to from the program code.
unsigned int word; unsigned int word;
MNEM_TAB *p;
const MNEM_TAB *p;


p = reserved_phonemes; p = reserved_phonemes;
while (p->mnem != NULL) { while (p->mnem != NULL) {


#define N_TUNE_NAMES 100 #define N_TUNE_NAMES 100


MNEM_TAB envelope_names[] = {
static const MNEM_TAB envelope_names[] = {
{ "fall", 0 }, { "fall", 0 },
{ "rise", 2 }, { "rise", 2 },
{ "fall-rise", 4 }, { "fall-rise", 4 },

+ 3
- 3
src/libespeak-ng/compiledict.c View File



static char letterGroupsDefined[N_LETTER_GROUPS]; static char letterGroupsDefined[N_LETTER_GROUPS];


MNEM_TAB mnem_rules[] = {
static const MNEM_TAB mnem_rules[] = {
{ "unpr", DOLLAR_UNPR }, { "unpr", DOLLAR_UNPR },
{ "noprefix", DOLLAR_NOPREFIX }, // rule fails if a prefix has been removed { "noprefix", DOLLAR_NOPREFIX }, // rule fails if a prefix has been removed
{ "list", DOLLAR_LIST }, // a pronunciation is given in the *_list file { "list", DOLLAR_LIST }, // a pronunciation is given in the *_list file
{ NULL, -1 } { 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 // these in the first group put a value in bits0-3 of dictionary_flags
{ "$1", 0x41 }, // stress on 1st syllable { "$1", 0x41 }, // stress on 1st syllable
{ "$2", 0x42 }, // stress on 2nd syllable { "$2", 0x42 }, // stress on 2nd syllable
bool literal; bool literal;
bool hexdigit_input = false; bool hexdigit_input = false;
int state = *state_out; int state = *state_out;
MNEM_TAB *mr;
const MNEM_TAB *mr;


if (string[0] == 0) return; if (string[0] == 0) return;



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

#include "translate.h" // for LEADING_2_BITS, UTF8_TAIL_BITS #include "translate.h" // for LEADING_2_BITS, UTF8_TAIL_BITS


// http://www.iana.org/assignments/character-sets/character-sets.xhtml // 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-1968", ESPEAKNG_ENCODING_US_ASCII },
{ "ANSI_X3.4-1986", ESPEAKNG_ENCODING_US_ASCII }, { "ANSI_X3.4-1986", ESPEAKNG_ENCODING_US_ASCII },
{ "ASMO-708", ESPEAKNG_ENCODING_ISO_8859_6 }, { "ASMO-708", ESPEAKNG_ENCODING_ISO_8859_6 },

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



#include "mnemonics.h" // for MNEM_TAB, LookupMnem, LookupMnemName #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) { while (table->mnem != NULL) {
if (string && strcmp(string, table->mnem) == 0) if (string && strcmp(string, table->mnem) == 0)
return table->value; 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) { while (table->mnem != NULL) {
if (table->value == value) if (table->value == value)

+ 2
- 2
src/libespeak-ng/mnemonics.h View File

const char *mnem; const char *mnem;
int value; int value;
} MNEM_TAB; } 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 #ifdef __cplusplus
} }

+ 1
- 1
src/libespeak-ng/sintab.h View File

{ {
#endif #endif


short int sin_tab[2048] = {
const short int sin_tab[2048] = {
0, -25, -50, -75, -100, -125, -150, -175, 0, -25, -50, -75, -100, -125, -150, -175,
-201, -226, -251, -276, -301, -326, -351, -376, -201, -226, -251, -276, -301, -326, -351, -376,
-401, -427, -452, -477, -502, -527, -552, -577, -401, -427, -452, -477, -502, -527, -552, -577,

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

#include "translate.h" // for CTRL_EMBEDDED, IsDigit09, utf8_out #include "translate.h" // for CTRL_EMBEDDED, IsDigit09, utf8_out
#include "voice.h" // for SelectVoice, SelectVoiceByName #include "voice.h" // for SelectVoice, SelectVoiceByName


static MNEM_TAB ssmltags[] = {
static const MNEM_TAB ssmltags[] = {
{ "speak", SSML_SPEAK }, { "speak", SSML_SPEAK },
{ "voice", SSML_VOICE }, { "voice", SSML_VOICE },
{ "prosody", SSML_PROSODY }, { "prosody", SSML_PROSODY },
static int ReplaceKeyName(char *outbuf, int index, int *outix) static int ReplaceKeyName(char *outbuf, int index, int *outix)
{ {
// Replace some key-names by single characters, so they can be pronounced in different languages // 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 }, { "space ", 0xe020 },
{ "tab ", 0xe009 }, { "tab ", 0xe009 },
{ "underscore ", 0xe05f }, { "underscore ", 0xe05f },
return 0; return 0;
} }


static MNEM_TAB xml_entity_mnemonics[] = {
static const MNEM_TAB xml_entity_mnemonics[] = {
{ "gt", '>' }, { "gt", '>' },
{ "lt", 0xe000 + '<' }, // private usage area, to avoid confusion with XML tag { "lt", 0xe000 + '<' }, // private usage area, to avoid confusion with XML tag
{ "amp", '&' }, { "amp", '&' },

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

#include "translate.h" // for LANGUAGE_OPTIONS, DeleteTranslator #include "translate.h" // for LANGUAGE_OPTIONS, DeleteTranslator
#include "wavegen.h" // for InitBreath #include "wavegen.h" // for InitBreath


MNEM_TAB genders[] = {
static const MNEM_TAB genders[] = {
{ "male", ENGENDER_MALE }, { "male", ENGENDER_MALE },
{ "female", ENGENDER_FEMALE }, { "female", ENGENDER_FEMALE },
{ NULL, ENGENDER_MALE } { NULL, ENGENDER_MALE }
V_CONSONANTS V_CONSONANTS
}; };


static MNEM_TAB keyword_tab[] = {
static const MNEM_TAB keyword_tab[] = {
{ "name", V_NAME }, { "name", V_NAME },
{ "language", V_LANGUAGE }, { "language", V_LANGUAGE },
{ "gender", V_GENDER }, { "gender", V_GENDER },
&data[0], &data[1], &data[2], &data[3], &data[4], &data[5], &data[6], &data[7]); &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 // read a list of numbers from string p
// store them as flags in *flags // store them as flags in *flags
// the meaning of the numbers is bit ordinals, not integer values // the meaning of the numbers is bit ordinals, not integer values
} }
} }


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 0 if translator is set.
// Return 1 and print an error message for specified key if not // Return 1 and print an error message for specified key if not

Loading…
Cancel
Save