int OK_for_Locate(const char* name,char no_empty_graph_warning) { return OK_for_Locate_write_error(name,no_empty_graph_warning,NULL); }
int OK_for_Locate(const VersatileEncodingConfig* vec,const char* name,char no_empty_graph_warning) { return OK_for_Locate_write_error(vec,name,no_empty_graph_warning,NULL); }
/** * The same than main, but no call to setBufferMode. */ int main_Fst2Check(int argc,char* const argv[]) { if (argc==1) { usage(); return 0; } int check_recursion=0,tfst_check=0; int append_output=0; int display_statistics=0; char no_empty_graph_warning=0; char output[FILENAME_MAX]=""; Encoding encoding_output = DEFAULT_ENCODING_OUTPUT; int bom_output = DEFAULT_BOM_OUTPUT; int mask_encoding_compatibility_input = DEFAULT_MASK_ENCODING_COMPATIBILITY_INPUT; int val,index=-1; struct OptVars* vars=new_OptVars(); while (EOF!=(val=getopt_long_TS(argc,argv,optstring_Fst2Check,lopts_Fst2Check,&index,vars))) { switch(val) { case 'a': append_output=1; break; case 'y': check_recursion=1; break; case 'n': check_recursion=0; break; case 's': display_statistics=1; break; case 't': tfst_check=1; /* If we have a tfst sentence graph, we must not report * compilation failure in the case of an empty graph. It * may be because of a sentence graph previously emptied by ELAG */ no_empty_graph_warning=1; break; case 'e': no_empty_graph_warning=1; break; case 'h': usage(); free_OptVars(vars); return 0; case ':': if (index==-1) fatal_error("Missing argument for option -%c\n",vars->optopt); else fatal_error("Missing argument for option --%s\n",lopts_Fst2Check[index].name); case 'k': if (vars->optarg[0]=='\0') { fatal_error("Empty input_encoding argument\n"); } decode_reading_encoding_parameter(&mask_encoding_compatibility_input,vars->optarg); break; case 'q': if (vars->optarg[0]=='\0') { fatal_error("Empty output_encoding argument\n"); } decode_writing_encoding_parameter(&encoding_output,&bom_output,vars->optarg); break; case 'o': if (vars->optarg[0]=='\0') { fatal_error("You must specify a non empty output file name\n"); } strcpy(output,vars->optarg); break; case '?': if (index==-1) fatal_error("Invalid option -%c\n",vars->optopt); else fatal_error("Invalid option --%s\n",vars->optarg); break; } index=-1; } if (vars->optind!=argc-1) { free_OptVars(vars); error("Invalid arguments: rerun with --help\n"); return 1; } char fst2_file_name[FILENAME_MAX]; remove_extension(argv[vars->optind],fst2_file_name); strcpy(fst2_file_name,argv[vars->optind]); U_FILE* ferr=NULL; free_OptVars(vars); if (output[0]!=0) { if (append_output == 0) { ferr=u_fopen_creating_versatile_encoding(encoding_output,bom_output, output, U_WRITE); } else { ferr = u_fopen_versatile_encoding(encoding_output,bom_output,mask_encoding_compatibility_input | ALL_ENCODING_BOM_POSSIBLE,output,U_APPEND); } } if (display_statistics) { display_fst2_file_stat(fst2_file_name,ferr); } if (check_recursion) { if (!OK_for_Locate_write_error(fst2_file_name,no_empty_graph_warning,ferr)) { if (ferr != NULL) { u_fclose(ferr); } return 1; } } if (tfst_check) { if (!valid_sentence_automaton_write_error(fst2_file_name,ferr)) { if (ferr != NULL) { u_fclose(ferr); } return 1; } } if (ferr != NULL) { u_fclose(ferr); } if ((check_recursion) || (tfst_check)) { u_printf("%s fst2 check has succeeded\n",fst2_file_name); } return 0; }