| static FILE *f_phcontents; | static FILE *f_phcontents; | ||||
| static FILE *f_errors = NULL; | static FILE *f_errors = NULL; | ||||
| static FILE *f_prog_log = NULL; | static FILE *f_prog_log = NULL; | ||||
| static FILE *f_report; | |||||
| static FILE *f_in; | static FILE *f_in; | ||||
| static int f_in_linenum; | static int f_in_linenum; | ||||
| return p1->ph_mnemonic - p2->ph_mnemonic; | return p1->ph_mnemonic - p2->ph_mnemonic; | ||||
| } | } | ||||
| static void CompileReport(void) | |||||
| { | |||||
| int ix; | |||||
| int hash; | |||||
| int n; | |||||
| REF_HASH_TAB *p; | |||||
| REF_HASH_TAB **list; | |||||
| const char *data_path; | |||||
| int prev_table; | |||||
| int procedure_num; | |||||
| int prev_mnemonic; | |||||
| if (f_report == NULL || count_references == 0) | |||||
| return; | |||||
| // make a list of all the references and sort it | |||||
| list = (REF_HASH_TAB **)malloc((count_references)* sizeof(REF_HASH_TAB *)); | |||||
| if (list == NULL) | |||||
| return; | |||||
| fprintf(f_report, "\n%d phoneme tables\n", n_phoneme_tabs); | |||||
| fprintf(f_report, " new total\n"); | |||||
| for (ix = 0; ix < n_phoneme_tabs; ix++) | |||||
| fprintf(f_report, "%8s %3d %4d\n", phoneme_tab_list2[ix].name, phoneme_tab_list2[ix].n_phonemes, n_phcodes_list[ix]+1); | |||||
| fputc('\n', f_report); | |||||
| fprintf(f_report, "Data file Used by\n"); | |||||
| ix = 0; | |||||
| for (hash = 0; (hash < 256) && (ix < count_references); hash++) { | |||||
| p = ref_hash_tab[hash]; | |||||
| while (p != NULL) { | |||||
| list[ix++] = p; | |||||
| p = (REF_HASH_TAB *)(p->link); | |||||
| } | |||||
| } | |||||
| n = ix; | |||||
| qsort((void *)list, n, sizeof(REF_HASH_TAB *), (int (*)(const void *, const void *))ref_sorter); | |||||
| data_path = ""; | |||||
| prev_mnemonic = 0; | |||||
| prev_table = 0; | |||||
| for (ix = 0; ix < n; ix++) { | |||||
| int j = 0; | |||||
| if (strcmp(list[ix]->string, data_path) != 0) { | |||||
| data_path = list[ix]->string; | |||||
| j = strlen(data_path); | |||||
| fprintf(f_report, "%s", data_path); | |||||
| } else if ((list[ix]->ph_table == prev_table) && (list[ix]->ph_mnemonic == prev_mnemonic)) | |||||
| continue; // same phoneme, don't list twice | |||||
| while (j < 14) { | |||||
| fputc(' ', f_report); // pad filename with spaces | |||||
| j++; | |||||
| } | |||||
| prev_mnemonic = list[ix]->ph_mnemonic; | |||||
| if ((prev_mnemonic >> 24) == 'P') { | |||||
| // a procedure, not a phoneme | |||||
| procedure_num = atoi(WordToString(prev_mnemonic)); | |||||
| fprintf(f_report, " %s %s", phoneme_tab_list2[prev_table = list[ix]->ph_table].name, proc_names[procedure_num]); | |||||
| } else | |||||
| fprintf(f_report, " [%s] %s", WordToString(prev_mnemonic), phoneme_tab_list2[prev_table = list[ix]->ph_table].name); | |||||
| fputc('\n', f_report); | |||||
| } | |||||
| for (ix = 0; ix < n; ix++) { | |||||
| free(list[ix]); | |||||
| list[ix] = NULL; | |||||
| } | |||||
| free(list); | |||||
| list = NULL; | |||||
| } | |||||
| static void error(const char *format, ...) | static void error(const char *format, ...) | ||||
| { | { | ||||
| va_list args; | va_list args; | ||||
| if (f_in == NULL) | if (f_in == NULL) | ||||
| return create_file_error_context(context, errno, fname); | return create_file_error_context(context, errno, fname); | ||||
| sprintf(fname, "%s/%s", phsrc, "compile_report"); | |||||
| f_report = fopen(fname, "w"); | |||||
| if (f_report == NULL) { | |||||
| int error = errno; | |||||
| fclose(f_in); | |||||
| return create_file_error_context(context, error, fname); | |||||
| } | |||||
| sprintf(fname, "%s/%s", phdst, "phondata-manifest"); | sprintf(fname, "%s/%s", phdst, "phondata-manifest"); | ||||
| if ((f_phcontents = fopen(fname, "w")) == NULL) | if ((f_phcontents = fopen(fname, "w")) == NULL) | ||||
| f_phcontents = stderr; | f_phcontents = stderr; | ||||
| if (f_phdata == NULL) { | if (f_phdata == NULL) { | ||||
| int error = errno; | int error = errno; | ||||
| fclose(f_in); | fclose(f_in); | ||||
| fclose(f_report); | |||||
| fclose(f_phcontents); | fclose(f_phcontents); | ||||
| return create_file_error_context(context, error, fname); | return create_file_error_context(context, error, fname); | ||||
| } | } | ||||
| if (f_phindex == NULL) { | if (f_phindex == NULL) { | ||||
| int error = errno; | int error = errno; | ||||
| fclose(f_in); | fclose(f_in); | ||||
| fclose(f_report); | |||||
| fclose(f_phcontents); | fclose(f_phcontents); | ||||
| fclose(f_phdata); | fclose(f_phdata); | ||||
| return create_file_error_context(context, error, fname); | return create_file_error_context(context, error, fname); | ||||
| if (f_phtab == NULL) { | if (f_phtab == NULL) { | ||||
| int error = errno; | int error = errno; | ||||
| fclose(f_in); | fclose(f_in); | ||||
| fclose(f_report); | |||||
| fclose(f_phcontents); | fclose(f_phcontents); | ||||
| fclose(f_phdata); | fclose(f_phdata); | ||||
| fclose(f_phindex); | fclose(f_phindex); | ||||
| LoadPhData(NULL, NULL); | LoadPhData(NULL, NULL); | ||||
| CompileReport(); | |||||
| fclose(f_report); | |||||
| WavegenFini(); | WavegenFini(); | ||||
| if (resample_count > 0) { | if (resample_count > 0) { |