| 473 | |
| 474 | |
| 475 | static int parse_input_file(const char *file_name, struct errors **top_error, |
| 476 | struct languages **top_lang) |
| 477 | { |
| 478 | FILE *file; |
| 479 | char *str, buff[1000]; |
| 480 | struct errors *current_error= 0, **tail_error= top_error; |
| 481 | struct message current_message; |
| 482 | int rcount= 0; |
| 483 | DBUG_ENTER("parse_input_file"); |
| 484 | |
| 485 | *top_error= 0; |
| 486 | *top_lang= 0; |
| 487 | if (!(file= my_fopen(file_name, O_RDONLY | O_SHARE, MYF(MY_WME)))) |
| 488 | DBUG_RETURN(0); |
| 489 | |
| 490 | while ((str= fgets(buff, sizeof(buff), file))) |
| 491 | { |
| 492 | if (is_prefix(str, "language")) |
| 493 | { |
| 494 | if (!(*top_lang= parse_charset_string(str))) |
| 495 | { |
| 496 | fprintf(stderr, "Failed to parse the charset string!\n"); |
| 497 | DBUG_RETURN(0); |
| 498 | } |
| 499 | continue; |
| 500 | } |
| 501 | if (is_prefix(str, "start-error-number")) |
| 502 | { |
| 503 | if (!(er_offset= parse_error_offset(str))) |
| 504 | { |
| 505 | fprintf(stderr, "Failed to parse the error offset string!\n"); |
| 506 | DBUG_RETURN(0); |
| 507 | } |
| 508 | continue; |
| 509 | } |
| 510 | if (is_prefix(str, "default-language")) |
| 511 | { |
| 512 | if (!(default_language= parse_default_language(str))) |
| 513 | { |
| 514 | DBUG_PRINT("info", ("default_slang: %s", default_language)); |
| 515 | fprintf(stderr, |
| 516 | "Failed to parse the default language line. Aborting\n"); |
| 517 | DBUG_RETURN(0); |
| 518 | } |
| 519 | continue; |
| 520 | } |
| 521 | |
| 522 | if (*str == '\t' || *str == ' ') |
| 523 | { |
| 524 | /* New error message in another language for previous error */ |
| 525 | if (!current_error) |
| 526 | { |
| 527 | fprintf(stderr, "Error in the input file format\n"); |
| 528 | DBUG_RETURN(0); |
| 529 | } |
| 530 | if (!parse_message_string(¤t_message, str)) |
| 531 | { |
| 532 | fprintf(stderr, "Failed to parse message string for error '%s'", |
no test coverage detected