| @@ -2016,7 +2016,9 @@ int CompilePhoneme(int compile_phoneme) | |||
| error("Missing 'endphoneme' before end-of-file"); // end of file | |||
| break; | |||
| } | |||
| if (phoneme_add_feature(phoneme_out, item_string, NULL) == ENS_OK) | |||
| phoneme_feature_t feature = phoneme_feature_from_string(item_string); | |||
| if (phoneme_add_feature(phoneme_out, feature) == ENS_OK) | |||
| continue; | |||
| error("Bad keyword in phoneme definition '%s'", item_string); | |||
| continue; | |||
| @@ -74,27 +74,6 @@ create_version_mismatch_error_context(espeak_ng_ERROR_CONTEXT *context, | |||
| return ENS_VERSION_MISMATCH; | |||
| } | |||
| espeak_ng_STATUS | |||
| create_name_error_context(espeak_ng_ERROR_CONTEXT *context, | |||
| espeak_ng_STATUS status, | |||
| const char *name) | |||
| { | |||
| if (context) { | |||
| if (*context) { | |||
| free((*context)->name); | |||
| } else { | |||
| *context = malloc(sizeof(espeak_ng_ERROR_CONTEXT_)); | |||
| if (!*context) | |||
| return ENOMEM; | |||
| } | |||
| (*context)->type = ERROR_CONTEXT_NAME; | |||
| (*context)->name = strdup(name); | |||
| (*context)->version = 0; | |||
| (*context)->expected_version = 0; | |||
| } | |||
| return status; | |||
| } | |||
| #pragma GCC visibility push(default) | |||
| ESPEAK_NG_API void | |||
| @@ -182,9 +161,6 @@ espeak_ng_PrintStatusCodeMessage(espeak_ng_STATUS status, | |||
| fprintf(out, "Error: %s at '%s' (expected 0x%x, got 0x%x).\n", | |||
| error, context->name, context->expected_version, context->version); | |||
| break; | |||
| case ERROR_CONTEXT_NAME: | |||
| fprintf(out, "Error: %s (got \"%s\").\n", error, context->name); | |||
| break; | |||
| } | |||
| } else | |||
| fprintf(out, "Error: %s.\n", error); | |||
| @@ -27,7 +27,6 @@ typedef enum | |||
| { | |||
| ERROR_CONTEXT_FILE, | |||
| ERROR_CONTEXT_VERSION, | |||
| ERROR_CONTEXT_NAME, | |||
| } espeak_ng_CONTEXT_TYPE; | |||
| typedef struct espeak_ng_ERROR_CONTEXT_ | |||
| @@ -49,11 +48,6 @@ create_version_mismatch_error_context(espeak_ng_ERROR_CONTEXT *context, | |||
| int version, | |||
| int expected_version); | |||
| espeak_ng_STATUS | |||
| create_name_error_context(espeak_ng_ERROR_CONTEXT *context, | |||
| espeak_ng_STATUS status, | |||
| const char *name); | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| @@ -25,22 +25,20 @@ | |||
| #include <espeak-ng/speak_lib.h> | |||
| #include "phoneme.h" | |||
| #include "error.h" | |||
| uint32_t lookup_feature(const char *feature) { | |||
| if (strlen(feature) != 3) | |||
| phoneme_feature_t phoneme_feature_from_string(const char *feature) | |||
| { | |||
| if (!feature || strlen(feature) != 3) | |||
| return inv; | |||
| return (feature[0] << 16) | (feature[1] << 8) | feature[2]; | |||
| } | |||
| espeak_ng_STATUS | |||
| phoneme_add_feature(PHONEME_TAB *phoneme, | |||
| const char *feature, | |||
| espeak_ng_ERROR_CONTEXT *context) | |||
| phoneme_feature_t feature) | |||
| { | |||
| if (!phoneme || !feature) return EINVAL; | |||
| switch (lookup_feature(feature)) | |||
| if (!phoneme) return EINVAL; | |||
| switch (feature) | |||
| { | |||
| // manner of articulation | |||
| case nas: | |||
| @@ -220,7 +218,7 @@ phoneme_add_feature(PHONEME_TAB *phoneme, | |||
| break; | |||
| // invalid phoneme feature | |||
| default: | |||
| return create_name_error_context(context, ENS_UNKNOWN_PHONEME_FEATURE, feature); | |||
| return ENS_UNKNOWN_PHONEME_FEATURE; | |||
| } | |||
| return ENS_OK; | |||
| } | |||
| @@ -23,7 +23,7 @@ extern "C" | |||
| #endif | |||
| // See docs/phonemes.md for the list of supported features. | |||
| enum feature_t { | |||
| typedef enum { | |||
| # define FEATURE_T(a, b, c) ((a << 16) | (b << 8) | (c)) | |||
| // invalid phoneme feature name | |||
| inv = 0, | |||
| @@ -114,7 +114,9 @@ enum feature_t { | |||
| fts = FEATURE_T('f', 't', 's'), | |||
| lns = FEATURE_T('l', 'n', 's'), | |||
| # undef FEATURE_T | |||
| }; | |||
| } phoneme_feature_t; | |||
| phoneme_feature_t phoneme_feature_from_string(const char *feature); | |||
| // phoneme types | |||
| #define phPAUSE 0 | |||
| @@ -207,8 +209,7 @@ typedef struct { | |||
| espeak_ng_STATUS | |||
| phoneme_add_feature(PHONEME_TAB *phoneme, | |||
| const char *feature, | |||
| espeak_ng_ERROR_CONTEXT *context); | |||
| phoneme_feature_t feature); | |||
| // Several phoneme tables may be loaded into memory. phoneme_tab points to | |||
| // one for the current voice | |||