From b4297c28514d6a24bf7b98f6ed84c8e2b50d6627 Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Sat, 28 Jan 2017 12:37:41 +0000 Subject: [PATCH] compiledata: Display the actual error from phoneme_add_feature. --- CHANGELOG.md | 1 + src/libespeak-ng/compiledata.c | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45d2f250..b7eb1fd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The espeak-ng project is a fork of the espeak project. ### 1.49.2 - (In Development) * Support describing all IPA phonemes in the phoneme tables. +* Provide more validation when compiling phoneme tables. * Removed support for phoneme equivalence tables. These were disabled in the French and German language files. diff --git a/src/libespeak-ng/compiledata.c b/src/libespeak-ng/compiledata.c index 89bbca79..f83a512d 100644 --- a/src/libespeak-ng/compiledata.c +++ b/src/libespeak-ng/compiledata.c @@ -584,6 +584,16 @@ static void error(const char *format, ...) va_end(args); } +static void error_from_status(espeak_ng_STATUS status, const char *context) +{ + char message[512]; + espeak_ng_GetStatusCodeMessage(status, message, sizeof(message)); + if (context) + error("%s: '%s'.", message, context); + else + error("%s.", message); +} + static unsigned int StringToWord(const char *string) { // Pack 4 characters into a word @@ -2012,9 +2022,10 @@ int CompilePhoneme(int compile_phoneme) } phoneme_feature_t feature = phoneme_feature_from_string(item_string); - if (phoneme_add_feature(phoneme_out, feature) == ENS_OK) + espeak_ng_STATUS status = phoneme_add_feature(phoneme_out, feature); + if (status == ENS_OK) continue; - error("Bad keyword in phoneme definition '%s'", item_string); + error_from_status(status, item_string); continue; }