Browse Source

Remove the uses of fopen_log in compiledata.c.

master
Reece H. Dunn 9 years ago
parent
commit
a675073381
1 changed files with 4 additions and 16 deletions
  1. 4
    16
      src/libespeak-ng/compiledata.c

+ 4
- 16
src/libespeak-ng/compiledata.c View File

va_end(args); va_end(args);
} }


static FILE *fopen_log(FILE *f_log, const char *fname, const char *access)
{
// performs fopen, but produces error message to f_log if it fails
FILE *f;

if ((f = fopen(fname, access)) == NULL) {
if (f_log != NULL)
fprintf(f_log, "Can't access (%s) file '%s'\n", access, fname);
}
return f;
}

static unsigned int StringToWord(const char *string) static unsigned int StringToWord(const char *string)
{ {
// Pack 4 characters into a word // Pack 4 characters into a word
NextItem(tSTRING); NextItem(tSTRING);
sprintf(buf, "%s/../phsource/%s", path_home, item_string); sprintf(buf, "%s/../phsource/%s", path_home, item_string);


if ((stack_ix < N_STACK) && (f = fopen_log(f_errors, buf, "rb")) != NULL) {
if ((stack_ix < N_STACK) && (f = fopen(buf, "rb")) != NULL) {
stack[stack_ix].linenum = linenum; stack[stack_ix].linenum = linenum;
strcpy(stack[stack_ix].fname, current_fname); strcpy(stack[stack_ix].fname, current_fname);
stack[stack_ix++].file = f_in; stack[stack_ix++].file = f_in;
return create_file_error_context(context, errno, fname); return create_file_error_context(context, errno, fname);


sprintf(fname, "%s/../phsource/%s", path_home, "compile_report"); sprintf(fname, "%s/../phsource/%s", path_home, "compile_report");
f_report = fopen_log(f_errors, fname, "w");
f_report = fopen(fname, "w");
if (f_report == NULL) { if (f_report == NULL) {
int error = errno; int error = errno;
fclose(f_in); fclose(f_in);
} }


sprintf(fname, "%s/%s", path_home, "phondata-manifest"); sprintf(fname, "%s/%s", path_home, "phondata-manifest");
if ((f_phcontents = fopen_log(f_phcontents, fname, "w")) == NULL)
if ((f_phcontents = fopen(fname, "w")) == NULL)
f_phcontents = stderr; f_phcontents = stderr;


fprintf(f_phcontents, fprintf(f_phcontents,
} }


sprintf(fname, "%s/../phsource/compile_prog_log", path_home); sprintf(fname, "%s/../phsource/compile_prog_log", path_home);
f_prog_log = fopen_log(f_errors, fname, "wb");
f_prog_log = fopen(fname, "wb");


fprintf(log, "Compiling phoneme data: %s/../phsource\n", path_home); fprintf(log, "Compiling phoneme data: %s/../phsource\n", path_home);



Loading…
Cancel
Save