From f9ea83430e76cfff9b1ad2cb9fa46979f0dbbb6e Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Sat, 2 Jan 2016 11:58:12 +0000 Subject: [PATCH] Use errno codes in place of ENE_(READ|WRITE)_ERROR. --- src/include/espeak-ng/espeak_ng.h | 2 -- src/libespeak-ng/compiledata.c | 14 ++++++++------ src/libespeak-ng/compiledict.c | 8 +++++--- src/libespeak-ng/compilembrola.c | 7 ++++--- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/include/espeak-ng/espeak_ng.h b/src/include/espeak-ng/espeak_ng.h index acfbf94e..67e72350 100644 --- a/src/include/espeak-ng/espeak_ng.h +++ b/src/include/espeak-ng/espeak_ng.h @@ -37,8 +37,6 @@ typedef enum { /* Error Codes (< 0) */ - ENE_READ_ERROR = -1, - ENE_WRITE_ERROR = -2, ENE_COMPILE_ERRORS = -4, ENE_VERSION_MISMATCH = -5, } espeak_ng_STATUS; diff --git a/src/libespeak-ng/compiledata.c b/src/libespeak-ng/compiledata.c index 2b7c9a74..450758be 100644 --- a/src/libespeak-ng/compiledata.c +++ b/src/libespeak-ng/compiledata.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2005 to 2014 by Jonathan Duddington * email: jonsd@users.sourceforge.net - * Copyright (C) 2013-2015 Reece H. Dunn + * Copyright (C) 2013-2016 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 @@ -2650,7 +2650,7 @@ static espeak_ng_STATUS CompilePhonemeData2(const char *source, FILE *log) if (!access(fname, 755)) { fprintf(log, "Can't find phoneme source directory: %s\n", fname); - return ENE_READ_ERROR; + return errno; } strncpy0(current_fname, source, sizeof(current_fname)); @@ -2659,7 +2659,7 @@ static espeak_ng_STATUS CompilePhonemeData2(const char *source, FILE *log) f_in = fopen_log(f_errors, fname, "rb"); if (f_in == NULL) { fprintf(log, "Can't read master phonemes file: %s\n", fname); - return ENE_READ_ERROR; + return errno; } sprintf(fname, "%s/../phsource/%s", path_home, "compile_report"); @@ -2695,7 +2695,7 @@ static espeak_ng_STATUS CompilePhonemeData2(const char *source, FILE *log) f_phtab = fopen_log(f_errors, fname, "wb"); if (f_phdata == NULL || f_phindex == NULL || f_phtab == NULL) - return ENE_WRITE_ERROR; + return errno; sprintf(fname, "%s/../phsource/compile_prog_log", path_home); f_prog_log = fopen_log(f_errors, fname, "wb"); @@ -2814,9 +2814,10 @@ espeak_ng_STATUS espeak_ng_CompileIntonation(FILE *log) if ((f_in = fopen(buf, "r")) == NULL) { sprintf(buf, "%s/../phsource/intonation", path_home); if ((f_in = fopen_log(f_errors, buf, "r")) == NULL) { + int error = errno; fprintf(log, "Can't read file: %s\n", buf); fclose(f_errors); - return ENE_READ_ERROR; + return error; } } @@ -2869,10 +2870,11 @@ espeak_ng_STATUS espeak_ng_CompileIntonation(FILE *log) sprintf(buf, "%s/intonations", path_home); f_out = fopen_log(f_errors, buf, "wb"); if (f_out == NULL) { + int error = errno; fclose(f_in); fclose(f_errors); free(tune_data); - return ENE_WRITE_ERROR; + return error; } while (!feof(f_in)) { diff --git a/src/libespeak-ng/compiledict.c b/src/libespeak-ng/compiledict.c index 31c94af2..74f764a8 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 Reece H. Dunn + * Copyright (C) 2015-2016 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 @@ -20,6 +20,7 @@ #include "config.h" +#include #include #include #include @@ -1549,13 +1550,14 @@ ESPEAK_NG_API espeak_ng_STATUS espeak_ng_CompileDictionary(const char *dsource, if ((f_in = fopen(fname_in, "r")) == NULL) { sprintf(fname_in, "%srules", path); if ((f_in = fopen_log(fname_in, "r")) == NULL) - return ENE_READ_ERROR; + return errno; } sprintf(fname_out, "%s%c%s_dict", path_home, PATHSEP, dict_name); if ((f_out = fopen_log(fname_out, "wb+")) == NULL) { + int error = errno; fclose(f_in); - return ENE_WRITE_ERROR; + return error; } sprintf(fname_temp, "%s%ctemp", path_home, PATHSEP); diff --git a/src/libespeak-ng/compilembrola.c b/src/libespeak-ng/compilembrola.c index 3deb8a99..ca8dc88b 100644 --- a/src/libespeak-ng/compilembrola.c +++ b/src/libespeak-ng/compilembrola.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2005 to 2014 by Jonathan Duddington * email: jonsd@users.sourceforge.net - * Copyright (C) 2013-2015 Reece H. Dunn + * Copyright (C) 2013-2016 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 @@ -19,6 +19,7 @@ #include "config.h" +#include #include #include #include @@ -86,7 +87,7 @@ espeak_ng_STATUS espeak_ng_CompileMbrolaVoice(const char *filepath, FILE *log) strcpy(buf, filepath); if ((f_in = fopen(buf, "r")) == NULL) { fprintf(log, "Can't read: %s\n", filepath); - return ENE_READ_ERROR; + return errno; } while (fgets(buf, sizeof(phoneme), f_in) != NULL) { @@ -127,7 +128,7 @@ espeak_ng_STATUS espeak_ng_CompileMbrolaVoice(const char *filepath, FILE *log) sprintf(buf, "%s/mbrola_ph/%s_phtrans", path_home, mbrola_voice); if ((f_out = fopen(buf, "wb")) == NULL) { fprintf(log, "Can't write to: %s\n", buf); - return ENE_WRITE_ERROR; + return errno; } data[count].name = 0; // list terminator