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

@@ -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:

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

@@ -1,7 +1,7 @@
/*
* Copyright (C) 2005 to 2014 by Jonathan Duddington
* 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
* 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;

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

@@ -1,7 +1,7 @@
/*
* Copyright (C) 2005 to 2014 by Jonathan Duddington
* 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
* 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

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

@@ -17,24 +17,10 @@

#include "config.h"

#include <string.h>

#include <espeak-ng/espeak_ng.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[] = {
{ 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

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

@@ -0,0 +1,46 @@
/*
* 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

@@ -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);


Loading…
Cancel
Save