diff --git a/Makefile.am b/Makefile.am index 73f73bb1..567bc82c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -151,6 +151,7 @@ src_libespeak_ng_la_SOURCES = \ src/libespeak-ng/espeak_api.c \ src/libespeak-ng/ieee80.c \ src/libespeak-ng/intonation.c \ + src/libespeak-ng/mnemonics.c \ src/libespeak-ng/numbers.c \ src/libespeak-ng/readclause.c \ src/libespeak-ng/phoneme.c \ @@ -212,6 +213,7 @@ noinst_bin_PROGRAMS += tests/encoding.test tests_encoding_test_CFLAGS = -Isrc/libespeak-ng -Isrc/include -D _POSIX_C_SOURCE=200112L ${AM_CFLAGS} tests_encoding_test_SOURCES = \ src/libespeak-ng/encoding.c \ + src/libespeak-ng/mnemonics.c \ tests/encoding.c ##### phoneme data: diff --git a/src/libespeak-ng/compiledict.c b/src/libespeak-ng/compiledict.c index 55ebb78b..7bd022e2 100644 --- a/src/libespeak-ng/compiledict.c +++ b/src/libespeak-ng/compiledict.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2005 to 2014 by Jonathan Duddington * email: jonsd@users.sourceforge.net - * 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 * it under the terms of the GNU General Public License as published by @@ -173,17 +173,6 @@ int isspace2(unsigned int c) 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) { int stress; diff --git a/src/libespeak-ng/dictionary.c b/src/libespeak-ng/dictionary.c index 98616e63..5801d26d 100644 --- a/src/libespeak-ng/dictionary.c +++ b/src/libespeak-ng/dictionary.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2005 to 2014 by Jonathan Duddington * email: jonsd@users.sourceforge.net - * 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 * it under the terms of the GNU General Public License as published by @@ -104,16 +104,6 @@ int Reverse4Bytes(int word) #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) { // Called after dictionary 1 is loaded, to set up table of entry points for translation rule chains diff --git a/src/libespeak-ng/encoding.c b/src/libespeak-ng/encoding.c index 71605ad0..550c49a2 100644 --- a/src/libespeak-ng/encoding.c +++ b/src/libespeak-ng/encoding.c @@ -17,24 +17,10 @@ #include "config.h" -#include - #include #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[] = { { NULL, ESPEAKNG_ENCODING_UNKNOWN } }; @@ -44,7 +30,7 @@ MNEM_TAB mnem_encoding[] = { espeak_ng_ENCODING espeak_ng_EncodingFromName(const char *encoding) { - return LookupMnemValue(mnem_encoding, encoding); + return LookupMnem(mnem_encoding, encoding); } #pragma GCC visibility pop diff --git a/src/libespeak-ng/mnemonics.c b/src/libespeak-ng/mnemonics.c new file mode 100644 index 00000000..9bc90a9a --- /dev/null +++ b/src/libespeak-ng/mnemonics.c @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2005 to 2014 by Jonathan Duddington + * email: jonsd@users.sourceforge.net + * 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: . + */ + +#include "config.h" + +#include + +#include + +#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 +} diff --git a/src/libespeak-ng/speech.h b/src/libespeak-ng/speech.h index cc14e20c..6f703b87 100644 --- a/src/libespeak-ng/speech.h +++ b/src/libespeak-ng/speech.h @@ -64,6 +64,7 @@ typedef struct { int value; } MNEM_TAB; int LookupMnem(MNEM_TAB *table, const char *string); +const char *LookupMnemName(MNEM_TAB *table, const int value); void cancel_audio(void);