Browse Source

Group the LookupMnem API implementations into mnemonics.c.

master
Reece H. Dunn 8 years ago
parent
commit
d5d93be00e

+ 2
- 0
Makefile.am View File

src/libespeak-ng/espeak_api.c \ src/libespeak-ng/espeak_api.c \
src/libespeak-ng/ieee80.c \ src/libespeak-ng/ieee80.c \
src/libespeak-ng/intonation.c \ src/libespeak-ng/intonation.c \
src/libespeak-ng/mnemonics.c \
src/libespeak-ng/numbers.c \ src/libespeak-ng/numbers.c \
src/libespeak-ng/readclause.c \ src/libespeak-ng/readclause.c \
src/libespeak-ng/phoneme.c \ src/libespeak-ng/phoneme.c \
tests_encoding_test_CFLAGS = -Isrc/libespeak-ng -Isrc/include -D _POSIX_C_SOURCE=200112L ${AM_CFLAGS} tests_encoding_test_CFLAGS = -Isrc/libespeak-ng -Isrc/include -D _POSIX_C_SOURCE=200112L ${AM_CFLAGS}
tests_encoding_test_SOURCES = \ tests_encoding_test_SOURCES = \
src/libespeak-ng/encoding.c \ src/libespeak-ng/encoding.c \
src/libespeak-ng/mnemonics.c \
tests/encoding.c tests/encoding.c


##### phoneme data: ##### phoneme data:

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

/* /*
* Copyright (C) 2005 to 2014 by Jonathan Duddington * Copyright (C) 2005 to 2014 by Jonathan Duddington
* email: [email protected] * email: [email protected]
* Copyright (C) 2015-2016 Reece H. Dunn
* Copyright (C) 2015-2017 Reece H. Dunn
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
return 1; return 1;
} }


// Lookup a mnemonic string in a table, return its name
const char *LookupMnemName(MNEM_TAB *table, const int value)
{
while (table->mnem != NULL) {
if (table->value == value)
return table->mnem;
table++;
}
return ""; // not found
}

void print_dictionary_flags(unsigned int *flags, char *buf, int buf_len) void print_dictionary_flags(unsigned int *flags, char *buf, int buf_len)
{ {
int stress; int stress;

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

/* /*
* Copyright (C) 2005 to 2014 by Jonathan Duddington * Copyright (C) 2005 to 2014 by Jonathan Duddington
* email: [email protected] * email: [email protected]
* Copyright (C) 2013-2016 Reece H. Dunn
* Copyright (C) 2013-2017 Reece H. Dunn
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
#endif #endif
} }


int LookupMnem(MNEM_TAB *table, const char *string)
{
while (table->mnem != NULL) {
if (strcmp(string, table->mnem) == 0)
return table->value;
table++;
}
return table->value;
}

static void InitGroups(Translator *tr) static void InitGroups(Translator *tr)
{ {
// Called after dictionary 1 is loaded, to set up table of entry points for translation rule chains // Called after dictionary 1 is loaded, to set up table of entry points for translation rule chains

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



#include "config.h" #include "config.h"


#include <string.h>

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


#include "speech.h" #include "speech.h"


static int
LookupMnemValue(MNEM_TAB *table,
const char *string)
{
while (table->mnem != NULL) {
if (strcmp(string, table->mnem) == 0)
return table->value;
table++;
}
return table->value;
}

MNEM_TAB mnem_encoding[] = { MNEM_TAB mnem_encoding[] = {
{ NULL, ESPEAKNG_ENCODING_UNKNOWN } { NULL, ESPEAKNG_ENCODING_UNKNOWN }
}; };
espeak_ng_ENCODING espeak_ng_ENCODING
espeak_ng_EncodingFromName(const char *encoding) espeak_ng_EncodingFromName(const char *encoding)
{ {
return LookupMnemValue(mnem_encoding, encoding);
return LookupMnem(mnem_encoding, encoding);
} }


#pragma GCC visibility pop #pragma GCC visibility pop

+ 46
- 0
src/libespeak-ng/mnemonics.c View File

/*
* Copyright (C) 2005 to 2014 by Jonathan Duddington
* email: [email protected]
* Copyright (C) 2013-2017 Reece H. Dunn
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see: <http://www.gnu.org/licenses/>.
*/

#include "config.h"

#include <string.h>

#include <espeak-ng/espeak_ng.h>

#include "speech.h"

int LookupMnem(MNEM_TAB *table, const char *string)
{
while (table->mnem != NULL) {
if (strcmp(string, table->mnem) == 0)
return table->value;
table++;
}
return table->value;
}

const char *LookupMnemName(MNEM_TAB *table, const int value)
{
while (table->mnem != NULL) {
if (table->value == value)
return table->mnem;
table++;
}
return ""; // not found
}

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

int value; int value;
} MNEM_TAB; } MNEM_TAB;
int LookupMnem(MNEM_TAB *table, const char *string); int LookupMnem(MNEM_TAB *table, const char *string);
const char *LookupMnemName(MNEM_TAB *table, const int value);


void cancel_audio(void); void cancel_audio(void);



Loading…
Cancel
Save