MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / parse_input_file

Function parse_input_file

extra/comp_err.c:475–590  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

473
474
475static 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(&current_message, str))
531 {
532 fprintf(stderr, "Failed to parse message string for error '%s'",

Callers 1

mainFunction · 0.85

Calls 12

my_fopenFunction · 0.85
is_prefixFunction · 0.85
parse_charset_stringFunction · 0.85
parse_error_offsetFunction · 0.85
parse_default_languageFunction · 0.85
parse_message_stringFunction · 0.85
find_messageFunction · 0.85
check_message_formatFunction · 0.85
insert_dynamicFunction · 0.85
parse_padd_stringFunction · 0.85
parse_error_stringFunction · 0.85
my_fcloseFunction · 0.85

Tested by

no test coverage detected