From 563e4e37695f9e95b344bdc9213969cf8f557abb Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Sat, 2 Jan 2016 12:20:25 +0000 Subject: [PATCH] Use ENS_ for eSpeak NG error codes, and standardize on a numbering scheme. --- src/espeak-ng.c | 2 +- src/include/espeak-ng/espeak_ng.h | 13 ++++++------- src/libespeak-ng/compiledata.c | 4 ++-- src/libespeak-ng/compiledict.c | 2 +- src/libespeak-ng/speak_lib.c | 2 +- src/libespeak-ng/synthdata.c | 2 +- src/speak-ng.c | 2 +- 7 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/espeak-ng.c b/src/espeak-ng.c index f60ecde1..25b56737 100644 --- a/src/espeak-ng.c +++ b/src/espeak-ng.c @@ -590,7 +590,7 @@ int main(int argc, char **argv) espeak_ng_InitializePath(data_path); espeak_ng_STATUS result = espeak_ng_Initialize(); if (result != ENS_OK) { - if (result == ENE_VERSION_MISMATCH) + if (result == ENS_VERSION_MISMATCH) fprintf(stderr, "Wrong version of espeak-data\n"); else fprintf(stderr, "Failed to load espeak-data\n"); diff --git a/src/include/espeak-ng/espeak_ng.h b/src/include/espeak-ng/espeak_ng.h index 67e72350..4103d14c 100644 --- a/src/include/espeak-ng/espeak_ng.h +++ b/src/include/espeak-ng/espeak_ng.h @@ -31,14 +31,13 @@ extern "C" #endif typedef enum { - ENS_OK = 0, + ENS_GROUP_MASK = 0x70000000, + ENS_GROUP_ERRNO = 0x00000000, /* Values 0-255 map to errno error codes. */ + ENS_GROUP_ESPEAK_NG = 0x10000000, /* eSpeak NG error codes. */ - /* 0 to 255 : errno */ - - /* Error Codes (< 0) */ - - ENE_COMPILE_ERRORS = -4, - ENE_VERSION_MISMATCH = -5, + ENS_OK = 0, + ENS_COMPILE_ERROR = 0x100001FF, + ENS_VERSION_MISMATCH = 0x100002FF, } espeak_ng_STATUS; typedef enum { diff --git a/src/libespeak-ng/compiledata.c b/src/libespeak-ng/compiledata.c index 450758be..a6a4352c 100644 --- a/src/libespeak-ng/compiledata.c +++ b/src/libespeak-ng/compiledata.c @@ -2740,7 +2740,7 @@ static espeak_ng_STATUS CompilePhonemeData2(const char *source, FILE *log) fclose(f_errors); ReadPhondataManifest(); - return error_count > 0 ? ENE_COMPILE_ERRORS : ENS_OK; + return error_count > 0 ? ENS_COMPILE_ERROR : ENS_OK; } static const char *preset_tune_names[] = { @@ -3032,7 +3032,7 @@ espeak_ng_STATUS espeak_ng_CompileIntonation(FILE *log) LoadPhData(NULL); - return error_count > 0 ? ENE_COMPILE_ERRORS : ENS_OK; + return error_count > 0 ? ENS_COMPILE_ERROR : ENS_OK; } espeak_ng_STATUS espeak_ng_CompilePhonemeData(long rate, FILE *log) diff --git a/src/libespeak-ng/compiledict.c b/src/libespeak-ng/compiledict.c index 74f764a8..b6a0971c 100644 --- a/src/libespeak-ng/compiledict.c +++ b/src/libespeak-ng/compiledict.c @@ -1593,6 +1593,6 @@ ESPEAK_NG_API espeak_ng_STATUS espeak_ng_CompileDictionary(const char *dsource, LoadDictionary(translator, dict_name, 0); - return error_count > 0 ? ENE_COMPILE_ERRORS : ENS_OK; + return error_count > 0 ? ENS_COMPILE_ERROR : ENS_OK; } #pragma GCC visibility pop diff --git a/src/libespeak-ng/speak_lib.c b/src/libespeak-ng/speak_lib.c index 41783895..95de809a 100644 --- a/src/libespeak-ng/speak_lib.c +++ b/src/libespeak-ng/speak_lib.c @@ -635,7 +635,7 @@ ESPEAK_API int espeak_Initialize(espeak_AUDIO_OUTPUT output_type, int buf_length espeak_ng_InitializePath(path); espeak_ng_STATUS result = espeak_ng_Initialize(); if (result != ENS_OK) { - if (result == ENE_VERSION_MISMATCH) + if (result == ENS_VERSION_MISMATCH) fprintf(stderr, "Wrong version of espeak-data (expected 0x%x) at %s\n", version_phdata, path_home); else { fprintf(stderr, "Failed to load espeak-data\n"); diff --git a/src/libespeak-ng/synthdata.c b/src/libespeak-ng/synthdata.c index ff48c182..edd086f7 100644 --- a/src/libespeak-ng/synthdata.c +++ b/src/libespeak-ng/synthdata.c @@ -141,7 +141,7 @@ espeak_ng_STATUS LoadPhData(int *srate) } if (version != version_phdata) - return ENE_VERSION_MISMATCH; + return ENS_VERSION_MISMATCH; // set up phoneme tables p = phoneme_tab_data; diff --git a/src/speak-ng.c b/src/speak-ng.c index 6070f26d..8256cee6 100644 --- a/src/speak-ng.c +++ b/src/speak-ng.c @@ -577,7 +577,7 @@ int main(int argc, char **argv) espeak_ng_InitializePath(data_path); espeak_ng_STATUS result = espeak_ng_Initialize(); if (result != ENS_OK) { - if (result == ENE_VERSION_MISMATCH) + if (result == ENS_VERSION_MISMATCH) fprintf(stderr, "Wrong version of espeak-data (expected 0x%x) at %s\n", version_phdata, path_home); else fprintf(stderr, "Failed to load espeak-data\n");