#include <my_global.h>#include <m_ctype.h>#include <my_sys.h>#include <m_string.h>#include <my_getopt.h>#include <assert.h>#include <my_dir.h>Include dependency graph for comp_err.c:

Go to the source code of this file.
Classes | |
| struct | message |
| struct | languages |
| struct | errors |
Defines | |
| #define | MAX_ROWS 1000 |
| #define | HEADER_LENGTH 32 |
| #define | DEFAULT_CHARSET_DIR "../sql/share/charsets" |
| #define | ER_PREFIX "ER_" |
| #define | WARN_PREFIX "WARN_" |
Functions | |
| static struct languages * | parse_charset_string (char *str) |
| static struct errors * | parse_error_string (char *ptr, int er_count) |
| static struct message * | parse_message_string (struct message *new_message, char *str) |
| static struct message * | find_message (struct errors *err, const char *lang, my_bool no_default) |
| static int | parse_input_file (const char *file_name, struct errors **top_error, struct languages **top_language) |
| static int | get_options (int *argc, char ***argv) |
| static void | print_version (void) |
| static void | usage (void) |
| static my_bool | get_one_option (int optid, const struct my_option *opt, char *argument) |
| static char * | parse_text_line (char *pos) |
| static int | copy_rows (FILE *to, char *row, int row_nr, long start_pos) |
| static char * | parse_default_language (char *str) |
| static uint | parse_error_offset (char *str) |
| static char * | skip_delimiters (char *str) |
| static char * | get_word (char **str) |
| static char * | find_end_of_word (char *str) |
| static void | clean_up (struct languages *lang_head, struct errors *error_head) |
| static int | create_header_files (struct errors *error_head) |
| static int | create_sys_files (struct languages *lang_head, struct errors *error_head, uint row_count) |
| int | main (int argc, char *argv[]) |
| static my_bool | get_one_option (int optid, const struct my_option *opt __attribute__((unused)), char *argument __attribute__((unused))) |
Variables | |
| static char * | OUTFILE = (char*) "errmsg.sys" |
| static char * | HEADERFILE = (char*) "mysqld_error.h" |
| static char * | NAMEFILE = (char*) "mysqld_ername.h" |
| static char * | STATEFILE = (char*) "sql_state.h" |
| static char * | TXTFILE = (char*) "../sql/share/errmsg.txt" |
| static char * | DATADIRECTORY = (char*) "../sql/share/" |
| static char * | default_dbug_option = (char*) "d:t:O,/tmp/comp_err.trace" |
| uchar | file_head [] = { 254, 254, 2, 1 } |
| uint | file_pos [MAX_ROWS] |
| const char * | empty_string = "" |
| const char * | default_language = "eng" |
| int | er_offset = 1000 |
| my_bool | info_flag = 0 |
| static struct my_option | my_long_options [] |
| #define DEFAULT_CHARSET_DIR "../sql/share/charsets" |
| #define ER_PREFIX "ER_" |
| #define HEADER_LENGTH 32 |
| #define MAX_ROWS 1000 |
Definition at line 34 of file comp_err.c.
| #define WARN_PREFIX "WARN_" |
Definition at line 356 of file comp_err.c.
References languages::charset, count, default_language, delete_dynamic(), dynamic_element, errors::er_name, languages::lang_long_name, languages::lang_short_name, errors::msg, my_free, MYF, errors::next_error, languages::next_lang, errors::sql_code1, and errors::sql_code2.
Referenced by main(), unireg_abort(), and unireg_end().
00357 { 00358 struct languages *tmp_lang, *next_language; 00359 struct errors *tmp_error, *next_error; 00360 uint count, i; 00361 00362 my_free((gptr) default_language, MYF(0)); 00363 00364 for (tmp_lang= lang_head; tmp_lang; tmp_lang= next_language) 00365 { 00366 next_language= tmp_lang->next_lang; 00367 my_free(tmp_lang->lang_short_name, MYF(0)); 00368 my_free(tmp_lang->lang_long_name, MYF(0)); 00369 my_free(tmp_lang->charset, MYF(0)); 00370 my_free((gptr) tmp_lang, MYF(0)); 00371 } 00372 00373 for (tmp_error= error_head; tmp_error; tmp_error= next_error) 00374 { 00375 next_error= tmp_error->next_error; 00376 count= (tmp_error->msg).elements; 00377 for (i= 0; i < count; i++) 00378 { 00379 struct message *tmp; 00380 tmp= dynamic_element(&tmp_error->msg, i, struct message*); 00381 my_free((gptr) tmp->lang_short_name, MYF(0)); 00382 my_free((gptr) tmp->text, MYF(0)); 00383 } 00384 00385 delete_dynamic(&tmp_error->msg); 00386 if (tmp_error->sql_code1[0]) 00387 my_free((gptr) tmp_error->sql_code1, MYF(0)); 00388 if (tmp_error->sql_code2[0]) 00389 my_free((gptr) tmp_error->sql_code2, MYF(0)); 00390 my_free((gptr) tmp_error->er_name, MYF(0)); 00391 my_free((gptr) tmp_error, MYF(0)); 00392 } 00393 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static int copy_rows | ( | FILE * | to, | |
| char * | row, | |||
| int | row_nr, | |||
| long | start_pos | |||
| ) | [static] |
Definition at line 951 of file comp_err.c.
References DBUG_ENTER, DBUG_RETURN, file_pos, and int().
Referenced by create_sys_files().
00952 { 00953 DBUG_ENTER("copy_rows"); 00954 00955 file_pos[row_nr]= (int) (ftell(to) - start_pos); 00956 if (fputs(row, to) == EOF || fputc('\0', to) == EOF) 00957 { 00958 fprintf(stderr, "Can't write to outputfile\n"); 00959 DBUG_RETURN(1); 00960 } 00961 00962 DBUG_RETURN(0); 00963 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static int create_header_files | ( | struct errors * | error_head | ) | [static] |
Definition at line 198 of file comp_err.c.
References errors::d_code, DBUG_ENTER, DBUG_RETURN, errors::er_name, HEADERFILE, LINT_INIT, my_fclose(), my_fopen(), MY_WME, MYF, NAMEFILE, errors::next_error, errors::sql_code1, errors::sql_code2, and STATEFILE.
Referenced by main().
00199 { 00200 uint er_last; 00201 FILE *er_definef, *sql_statef, *er_namef; 00202 struct errors *tmp_error; 00203 DBUG_ENTER("create_header_files"); 00204 LINT_INIT(er_last); 00205 00206 if (!(er_definef= my_fopen(HEADERFILE, O_WRONLY, MYF(MY_WME)))) 00207 { 00208 DBUG_RETURN(1); 00209 } 00210 if (!(sql_statef= my_fopen(STATEFILE, O_WRONLY, MYF(MY_WME)))) 00211 { 00212 my_fclose(er_definef, MYF(0)); 00213 DBUG_RETURN(1); 00214 } 00215 if (!(er_namef= my_fopen(NAMEFILE, O_WRONLY, MYF(MY_WME)))) 00216 { 00217 my_fclose(er_definef, MYF(0)); 00218 my_fclose(sql_statef, MYF(0)); 00219 DBUG_RETURN(1); 00220 } 00221 00222 fprintf(er_definef, "/* Autogenerated file, please don't edit */\n\n"); 00223 fprintf(sql_statef, "/* Autogenerated file, please don't edit */\n\n"); 00224 fprintf(er_namef, "/* Autogenerated file, please don't edit */\n\n"); 00225 00226 fprintf(er_definef, "#define ER_ERROR_FIRST %d\n", error_head->d_code); 00227 00228 for (tmp_error= error_head; tmp_error; tmp_error= tmp_error->next_error) 00229 { 00230 /* 00231 generating mysqld_error.h 00232 fprintf() will automatically add \r on windows 00233 */ 00234 fprintf(er_definef, "#define %s %d\n", tmp_error->er_name, 00235 tmp_error->d_code); 00236 er_last= tmp_error->d_code; 00237 00238 /* generating sql_state.h file */ 00239 if (tmp_error->sql_code1[0] || tmp_error->sql_code2[0]) 00240 fprintf(sql_statef, 00241 "%-40s,\"%s\", \"%s\",\n", tmp_error->er_name, 00242 tmp_error->sql_code1, tmp_error->sql_code2); 00243 /*generating er_name file */ 00244 fprintf(er_namef, "{ \"%s\", %d },\n", tmp_error->er_name, 00245 tmp_error->d_code); 00246 00247 } 00248 /* finishing off with mysqld_error.h */ 00249 fprintf(er_definef, "#define ER_ERROR_LAST %d\n", er_last); 00250 my_fclose(er_definef, MYF(0)); 00251 my_fclose(sql_statef, MYF(0)); 00252 my_fclose(er_namef, MYF(0)); 00253 DBUG_RETURN(0); 00254 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static int create_sys_files | ( | struct languages * | lang_head, | |
| struct errors * | error_head, | |||
| uint | row_count | |||
| ) | [static] |
Definition at line 257 of file comp_err.c.
References languages::charset, copy_rows(), DATADIRECTORY, DBUG_ENTER, DBUG_RETURN, errors::er_name, err, FALSE, FILE_BINARY, find_message(), FN_REFLEN, FN_ROOTDIR, get_charset_number(), HEADER_LENGTH, languages::lang_long_name, languages::lang_short_name, MY_CS_PRIMARY, my_fopen(), my_mkdir(), my_stat(), MY_STAT, MY_WME, MYF, errors::next_error, languages::next_lang, NullS, OUTFILE, outfile, strxmov(), message::text, to, and TXTFILE.
Referenced by main().
00259 { 00260 FILE *to; 00261 uint csnum= 0, length, i, row_nr; 00262 uchar head[32]; 00263 char outfile[FN_REFLEN], *outfile_end; 00264 long start_pos; 00265 struct message *tmp; 00266 struct languages *tmp_lang; 00267 struct errors *tmp_error; 00268 00269 MY_STAT stat_info; 00270 DBUG_ENTER("create_sys_files"); 00271 00272 /* 00273 going over all languages and assembling corresponding error messages 00274 */ 00275 for (tmp_lang= lang_head; tmp_lang; tmp_lang= tmp_lang->next_lang) 00276 { 00277 00278 /* setting charset name */ 00279 if (!(csnum= get_charset_number(tmp_lang->charset, MY_CS_PRIMARY))) 00280 { 00281 fprintf(stderr, "Unknown charset '%s' in '%s'\n", tmp_lang->charset, 00282 TXTFILE); 00283 DBUG_RETURN(1); 00284 } 00285 00286 outfile_end= strxmov(outfile, DATADIRECTORY, 00287 tmp_lang->lang_long_name, NullS); 00288 if (!my_stat(outfile, &stat_info,MYF(0))) 00289 { 00290 if (my_mkdir(outfile, 0777,MYF(0)) < 0) 00291 { 00292 fprintf(stderr, "Can't create output directory for %s\n", 00293 outfile); 00294 DBUG_RETURN(1); 00295 } 00296 } 00297 00298 strxmov(outfile_end, FN_ROOTDIR, OUTFILE, NullS); 00299 00300 if (!(to= my_fopen(outfile, O_WRONLY | FILE_BINARY, MYF(MY_WME)))) 00301 DBUG_RETURN(1); 00302 00303 /* 2 is for 2 bytes to store row position / error message */ 00304 start_pos= (long) (HEADER_LENGTH + row_count * 2); 00305 fseek(to, start_pos, 0); 00306 row_nr= 0; 00307 for (tmp_error= error_head; tmp_error; tmp_error= tmp_error->next_error) 00308 { 00309 /* dealing with messages */ 00310 tmp= find_message(tmp_error, tmp_lang->lang_short_name, FALSE); 00311 00312 if (!tmp) 00313 { 00314 fprintf(stderr, 00315 "Did not find message for %s neither in %s nor in default " 00316 "language\n", tmp_error->er_name, tmp_lang->lang_short_name); 00317 goto err; 00318 } 00319 if (copy_rows(to, tmp->text, row_nr, start_pos)) 00320 { 00321 fprintf(stderr, "Failed to copy rows to %s\n", outfile); 00322 goto err; 00323 } 00324 row_nr++; 00325 } 00326 00327 /* continue with header of the errmsg.sys file */ 00328 length= ftell(to) - HEADER_LENGTH - row_count * 2; 00329 bzero((gptr) head, HEADER_LENGTH); 00330 bmove((byte *) head, (byte *) file_head, 4); 00331 head[4]= 1; 00332 int2store(head + 6, length); 00333 int2store(head + 8, row_count); 00334 head[30]= csnum; 00335 00336 my_fseek(to, 0l, MY_SEEK_SET, MYF(0)); 00337 if (my_fwrite(to, (byte*) head, HEADER_LENGTH, MYF(MY_WME | MY_FNABP))) 00338 goto err; 00339 00340 for (i= 0; i < row_count; i++) 00341 { 00342 int2store(head, file_pos[i]); 00343 if (my_fwrite(to, (byte*) head, 2, MYF(MY_WME | MY_FNABP))) 00344 goto err; 00345 } 00346 my_fclose(to, MYF(0)); 00347 } 00348 DBUG_RETURN(0); 00349 00350 err: 00351 my_fclose(to, MYF(0)); 00352 DBUG_RETURN(1); 00353 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static char * find_end_of_word | ( | char * | str | ) | [static] |
Definition at line 623 of file comp_err.c.
References DBUG_ENTER, and DBUG_RETURN.
Referenced by get_word(), parse_charset_string(), parse_default_language(), and parse_error_offset().
00624 { 00625 DBUG_ENTER("find_end_of_word"); 00626 for (; 00627 *str != ' ' && *str != '\t' && *str != '\n' && *str != '\r' && *str && 00628 *str != ',' && *str != ';' && *str != '='; str++) 00629 ; 00630 DBUG_RETURN(str); 00631 }
Here is the caller graph for this function:

| static struct message * find_message | ( | struct errors * | err, | |
| const char * | lang, | |||
| my_bool | no_default | |||
| ) | [static] |
Definition at line 579 of file comp_err.c.
References count, DBUG_ASSERT, DBUG_ENTER, DBUG_RETURN, default_language, dynamic_element, message::lang_short_name, errors::msg, and strcmp().
Referenced by create_sys_files(), and parse_input_file().
00581 { 00582 struct message *tmp, *return_val= 0; 00583 uint i, count; 00584 DBUG_ENTER("find_message"); 00585 00586 count= (err->msg).elements; 00587 for (i= 0; i < count; i++) 00588 { 00589 tmp= dynamic_element(&err->msg, i, struct message*); 00590 00591 if (!strcmp(tmp->lang_short_name, lang)) 00592 DBUG_RETURN(tmp); 00593 if (!strcmp(tmp->lang_short_name, default_language)) 00594 { 00595 DBUG_ASSERT(tmp->text[0] != 0); 00596 return_val= tmp; 00597 } 00598 } 00599 DBUG_RETURN(no_default ? NULL : return_val); 00600 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static my_bool get_one_option | ( | int | optid, | |
| const struct my_option *opt | __attribute__((unused)), | |||
| char *argument | __attribute__((unused)) | |||
| ) | [static] |
Definition at line 855 of file comp_err.c.
References DBUG_ENTER, DBUG_PUSH, DBUG_RETURN, default_dbug_option, exit, print_version(), and usage().
00857 { 00858 DBUG_ENTER("get_one_option"); 00859 switch (optid) { 00860 case 'V': 00861 print_version(); 00862 exit(0); 00863 break; 00864 case '?': 00865 usage(); 00866 exit(0); 00867 break; 00868 case '#': 00869 DBUG_PUSH(argument ? argument : default_dbug_option); 00870 break; 00871 } 00872 DBUG_RETURN(0); 00873 }
Here is the call graph for this function:

| static int get_options | ( | int * | argc, | |
| char *** | argv | |||
| ) | [static] |
Definition at line 890 of file comp_err.c.
References DBUG_ENTER, DBUG_RETURN, get_one_option(), handle_options(), and my_long_options.
00891 { 00892 int ho_error; 00893 DBUG_ENTER("get_options"); 00894 00895 if ((ho_error= handle_options(argc, argv, my_long_options, get_one_option))) 00896 DBUG_RETURN(ho_error); 00897 DBUG_RETURN(0); 00898 }
Here is the call graph for this function:

| static char * get_word | ( | char ** | str | ) | [static] |
Definition at line 636 of file comp_err.c.
References DBUG_ENTER, DBUG_RETURN, find_end_of_word(), MY_FAE, my_strndup(), MY_WME, MYF, and start().
Referenced by get_text_id(), get_token(), Unset_option::parse_args(), Set_option::parse_args(), Create_instance::parse_args(), parse_charset_string(), parse_command(), parse_default_language(), parse_error_offset(), and parse_error_string().
00637 { 00638 char *start= *str; 00639 DBUG_ENTER("get_word"); 00640 00641 *str= find_end_of_word(start); 00642 DBUG_RETURN(my_strndup(start, (uint) (*str - start), 00643 MYF(MY_WME | MY_FAE))); 00644 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int main | ( | int | argc, | |
| char * | argv[] | |||
| ) |
Definition at line 157 of file comp_err.c.
References charsets_dir, clean_up(), create_header_files(), create_sys_files(), DBUG_ENTER, DBUG_LEAVE, DBUG_RETURN, DEFAULT_CHARSET_DIR, get_options(), info_flag, MY_CHECK_ERROR, my_end(), MY_GIVE_INFO, MY_INIT, NULL, parse_input_file(), and TXTFILE.
00158 { 00159 MY_INIT(argv[0]); 00160 { 00161 uint row_count; 00162 struct errors *error_head; 00163 struct languages *lang_head; 00164 DBUG_ENTER("main"); 00165 00166 charsets_dir= DEFAULT_CHARSET_DIR; 00167 if (get_options(&argc, &argv)) 00168 DBUG_RETURN(1); 00169 if (!(row_count= parse_input_file(TXTFILE, &error_head, &lang_head))) 00170 { 00171 fprintf(stderr, "Failed to parse input file %s\n", TXTFILE); 00172 DBUG_RETURN(1); 00173 } 00174 if (lang_head == NULL || error_head == NULL) 00175 { 00176 fprintf(stderr, "Failed to parse input file %s\n", TXTFILE); 00177 DBUG_RETURN(1); 00178 } 00179 00180 if (create_header_files(error_head)) 00181 { 00182 fprintf(stderr, "Failed to create header files\n"); 00183 DBUG_RETURN(1); 00184 } 00185 if (create_sys_files(lang_head, error_head, row_count)) 00186 { 00187 fprintf(stderr, "Failed to create sys files\n"); 00188 DBUG_RETURN(1); 00189 } 00190 clean_up(lang_head, error_head); 00191 DBUG_LEAVE; /* Can't use dbug after my_end() */ 00192 my_end(info_flag ? MY_CHECK_ERROR | MY_GIVE_INFO : 0); 00193 return 0; 00194 } 00195 }
Here is the call graph for this function:

| static struct languages * parse_charset_string | ( | char * | str | ) | [static] |
Definition at line 786 of file comp_err.c.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, find_end_of_word(), get_word(), my_malloc(), MY_WME, MYF, and skip_delimiters().
Referenced by parse_input_file().
00787 { 00788 struct languages *head=0, *new_lang; 00789 DBUG_ENTER("parse_charset_string"); 00790 DBUG_PRINT("enter", ("str: %s", str)); 00791 00792 /* skip over keyword */ 00793 str= find_end_of_word(str); 00794 if (!*str) 00795 { 00796 /* unexpected EOL */ 00797 DBUG_PRINT("info", ("str: %s", str)); 00798 DBUG_RETURN(0); 00799 } 00800 00801 str= skip_delimiters(str); 00802 if (!(*str != ';' && *str)) 00803 DBUG_RETURN(0); 00804 00805 do 00806 { 00807 /*creating new element of the linked list */ 00808 new_lang= (struct languages *) my_malloc(sizeof(*new_lang), MYF(MY_WME)); 00809 new_lang->next_lang= head; 00810 head= new_lang; 00811 00812 /* get the full language name */ 00813 00814 if (!(new_lang->lang_long_name= get_word(&str))) 00815 DBUG_RETURN(0); /* OOM: Fatal error */ 00816 00817 DBUG_PRINT("info", ("long_name: %s", new_lang->lang_long_name)); 00818 00819 /* getting the short name for language */ 00820 str= skip_delimiters(str); 00821 if (!*str) 00822 DBUG_RETURN(0); /* Error: No space or tab */ 00823 00824 if (!(new_lang->lang_short_name= get_word(&str))) 00825 DBUG_RETURN(0); /* OOM: Fatal error */ 00826 DBUG_PRINT("info", ("short_name: %s", new_lang->lang_short_name)); 00827 00828 /* getting the charset name */ 00829 str= skip_delimiters(str); 00830 if (!(new_lang->charset= get_word(&str))) 00831 DBUG_RETURN(0); /* Fatal error */ 00832 DBUG_PRINT("info", ("charset: %s", new_lang->charset)); 00833 00834 /* skipping space, tab or "," */ 00835 str= skip_delimiters(str); 00836 } 00837 while (*str != ';' && *str); 00838 00839 DBUG_PRINT("info", ("long name: %s", new_lang->lang_long_name)); 00840 DBUG_RETURN(head); 00841 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static char * parse_default_language | ( | char * | str | ) | [static] |
Definition at line 532 of file comp_err.c.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, find_end_of_word(), get_word(), and skip_delimiters().
Referenced by parse_input_file().
00533 { 00534 char *slang; 00535 00536 DBUG_ENTER("parse_default_language"); 00537 /* skipping the "default-language" keyword */ 00538 str= find_end_of_word(str); 00539 /* skipping space(s) and/or tabs after the keyword */ 00540 str= skip_delimiters(str); 00541 if (!*str) 00542 { 00543 fprintf(stderr, 00544 "Unexpected EOL: No short language name after the keyword\n"); 00545 DBUG_RETURN(0); 00546 } 00547 00548 /* reading the short language tag */ 00549 if (!(slang= get_word(&str))) 00550 DBUG_RETURN(0); /* OOM: Fatal error */ 00551 DBUG_PRINT("info", ("default_slang: %s", slang)); 00552 00553 str= skip_delimiters(str); 00554 DBUG_PRINT("info", ("str: %s", str)); 00555 if (*str) 00556 { 00557 fprintf(stderr, 00558 "The default language line does not end with short language " 00559 "name\n"); 00560 DBUG_RETURN(0); 00561 } 00562 DBUG_PRINT("info", ("str: %s", str)); 00563 DBUG_RETURN(slang); 00564 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static uint parse_error_offset | ( | char * | str | ) | [static] |
Definition at line 493 of file comp_err.c.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, error, find_end_of_word(), get_word(), my_free, my_strtoll10(), MYF, and skip_delimiters().
Referenced by parse_input_file().
00494 { 00495 char *soffset, *end; 00496 int error; 00497 uint ioffset; 00498 00499 DBUG_ENTER("parse_error_offset"); 00500 /* skipping the "start-error-number" keyword and spaces after it */ 00501 str= find_end_of_word(str); 00502 str= skip_delimiters(str); 00503 00504 if (!*str) 00505 DBUG_RETURN(0); /* Unexpected EOL: No error number after the keyword */ 00506 00507 /* reading the error offset */ 00508 if (!(soffset= get_word(&str))) 00509 DBUG_RETURN(0); /* OOM: Fatal error */ 00510 DBUG_PRINT("info", ("default_error_offset: %s", soffset)); 00511 00512 /* skipping space(s) and/or tabs after the error offset */ 00513 str= skip_delimiters(str); 00514 DBUG_PRINT("info", ("str: %s", str)); 00515 if (*str) 00516 { 00517 /* The line does not end with the error offset -> error! */ 00518 fprintf(stderr, "The error offset line does not end with an error offset"); 00519 DBUG_RETURN(0); 00520 } 00521 DBUG_PRINT("info", ("str: %s", str)); 00522 00523 end= 0; 00524 ioffset= (uint) my_strtoll10(soffset, &end, &error); 00525 my_free((gptr) soffset, MYF(0)); 00526 DBUG_RETURN(ioffset); 00527 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static struct errors * parse_error_string | ( | char * | ptr, | |
| int | er_count | |||
| ) | [static] |
Definition at line 710 of file comp_err.c.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, empty_string, er_offset, get_word(), my_init_dynamic_array, my_malloc(), MY_WME, MYF, skip_delimiters(), and start().
Referenced by parse_input_file().
00711 { 00712 struct errors *new_error; 00713 char *start; 00714 DBUG_ENTER("parse_error_string"); 00715 DBUG_PRINT("enter", ("str: %s", str)); 00716 00717 /* create a new element */ 00718 new_error= (struct errors *) my_malloc(sizeof(*new_error), MYF(MY_WME)); 00719 00720 if (my_init_dynamic_array(&new_error->msg, sizeof(struct message), 0, 0)) 00721 DBUG_RETURN(0); /* OOM: Fatal error */ 00722 00723 /* getting the error name */ 00724 start= str; 00725 str= skip_delimiters(str); 00726 00727 if (!(new_error->er_name= get_word(&str))) 00728 DBUG_RETURN(0); /* OOM: Fatal error */ 00729 DBUG_PRINT("info", ("er_name: %s", new_error->er_name)); 00730 00731 str= skip_delimiters(str); 00732 00733 /* getting the code1 */ 00734 00735 new_error->d_code= er_offset + er_count; 00736 DBUG_PRINT("info", ("d_code: %d", new_error->d_code)); 00737 00738 str= skip_delimiters(str); 00739 00740 /* if we reached EOL => no more codes, but this can happen */ 00741 if (!*str) 00742 { 00743 new_error->sql_code1= empty_string; 00744 new_error->sql_code2= empty_string; 00745 DBUG_PRINT("info", ("str: %s", str)); 00746 DBUG_RETURN(new_error); 00747 } 00748 00749 /* getting the sql_code 1 */ 00750 00751 if (!(new_error->sql_code1= get_word(&str))) 00752 DBUG_RETURN(0); /* OOM: Fatal error */ 00753 DBUG_PRINT("info", ("sql_code1: %s", new_error->sql_code1)); 00754 00755 str= skip_delimiters(str); 00756 00757 /* if we reached EOL => no more codes, but this can happen */ 00758 if (!*str) 00759 { 00760 new_error->sql_code2= empty_string; 00761 DBUG_PRINT("info", ("str: %s", str)); 00762 DBUG_RETURN(new_error); 00763 } 00764 00765 /* getting the sql_code 2 */ 00766 if (!(new_error->sql_code2= get_word(&str))) 00767 DBUG_RETURN(0); /* OOM: Fatal error */ 00768 DBUG_PRINT("info", ("sql_code2: %s", new_error->sql_code2)); 00769 00770 str= skip_delimiters(str); 00771 if (*str) 00772 { 00773 fprintf(stderr, "The error line did not end with sql/odbc code!"); 00774 DBUG_RETURN(0); 00775 } 00776 00777 DBUG_RETURN(new_error); 00778 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static int parse_input_file | ( | const char * | file_name, | |
| struct errors ** | top_error, | |||
| struct languages ** | top_language | |||
| ) | [static] |
Definition at line 396 of file comp_err.c.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, default_language, errors::er_name, er_offset, ER_PREFIX, find_message(), insert_dynamic(), is_prefix(), message::lang_short_name, errors::msg, my_fclose(), my_fopen(), MY_WME, MYF, errors::next_error, O_SHARE, parse_charset_string(), parse_default_language(), parse_error_offset(), parse_error_string(), parse_message_string(), TRUE, and WARN_PREFIX.
Referenced by main().
00398 { 00399 FILE *file; 00400 char *str, buff[1000]; 00401 struct errors *current_error= 0, **tail_error= top_error; 00402 struct message current_message; 00403 int rcount= 0; 00404 DBUG_ENTER("parse_input_file"); 00405 00406 if (!(file= my_fopen(file_name, O_RDONLY | O_SHARE, MYF(MY_WME)))) 00407 DBUG_RETURN(0); 00408 00409 while ((str= fgets(buff, sizeof(buff), file))) 00410 { 00411 if (is_prefix(str, "language")) 00412 { 00413 if (!(*top_lang= parse_charset_string(str))) 00414 { 00415 fprintf(stderr, "Failed to parse the charset string!\n"); 00416 DBUG_RETURN(0); 00417 } 00418 continue; 00419 } 00420 if (is_prefix(str, "start-error-number")) 00421 { 00422 if (!(er_offset= parse_error_offset(str))) 00423 { 00424 fprintf(stderr, "Failed to parse the error offset string!\n"); 00425 DBUG_RETURN(0); 00426 } 00427 continue; 00428 } 00429 if (is_prefix(str, "default-language")) 00430 { 00431 if (!(default_language= parse_default_language(str))) 00432 { 00433 DBUG_PRINT("info", ("default_slang: %s", default_language)); 00434 fprintf(stderr, 00435 "Failed to parse the default language line. Aborting\n"); 00436 DBUG_RETURN(0); 00437 } 00438 continue; 00439 } 00440 00441 if (*str == '\t' || *str == ' ') 00442 { 00443 /* New error message in another language for previous error */ 00444 if (!current_error) 00445 { 00446 fprintf(stderr, "Error in the input file format\n"); 00447 DBUG_RETURN(0); 00448 } 00449 if (!parse_message_string(¤t_message, str)) 00450 { 00451 fprintf(stderr, "Failed to parse message string for error '%s'", 00452 current_error->er_name); 00453 DBUG_RETURN(0); 00454 } 00455 if (find_message(current_error, current_message.lang_short_name, TRUE)) 00456 { 00457 fprintf(stderr, "Duplicate message string for error '%s'" 00458 " in language '%s'\n", 00459 current_error->er_name, current_message.lang_short_name); 00460 DBUG_RETURN(0); 00461 } 00462 if (insert_dynamic(¤t_error->msg, (byte *) & current_message)) 00463 DBUG_RETURN(0); 00464 continue; 00465 } 00466 if (is_prefix(str, ER_PREFIX) || is_prefix(str, WARN_PREFIX)) 00467 { 00468 if (!(current_error= parse_error_string(str, rcount))) 00469 { 00470 fprintf(stderr, "Failed to parse the error name string\n"); 00471 DBUG_RETURN(0); 00472 } 00473 rcount++; /* Count number of unique errors */ 00474 00475 /* add error to the list */ 00476 *tail_error= current_error; 00477 tail_error= ¤t_error->next_error; 00478 continue; 00479 } 00480 if (*str == '#' || *str == '\n') 00481 continue; /* skip comment or empty lines */ 00482 00483 fprintf(stderr, "Wrong input file format. Stop!\nLine: %s\n", str); 00484 DBUG_RETURN(0); 00485 } 00486 *tail_error= 0; /* Mark end of list */ 00487 00488 my_fclose(file, MYF(0)); 00489 DBUG_RETURN(rcount); 00490 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 652 of file comp_err.c.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, message::lang_short_name, MY_FAE, my_strndup(), MY_WME, MYF, parse_text_line(), start(), and message::text.
Referenced by parse_input_file().
00654 { 00655 char *start; 00656 00657 DBUG_ENTER("parse_message_string"); 00658 DBUG_PRINT("enter", ("str: %s", str)); 00659 00660 /*skip space(s) and/or tabs in the beginning */ 00661 while (*str == ' ' || *str == '\t' || *str == '\n') 00662 str++; 00663 00664 if (!*str) 00665 { 00666 /* It was not a message line, but an empty line. */ 00667 DBUG_PRINT("info", ("str: %s", str)); 00668 DBUG_RETURN(0); 00669 } 00670 00671 /* reading the short lang */ 00672 start= str; 00673 while (*str != ' ' && *str != '\t' && *str) 00674 str++; 00675 if (!(new_message->lang_short_name= 00676 my_strndup(start, (uint) (str - start), 00677 MYF(MY_WME | MY_FAE)))) 00678 DBUG_RETURN(0); /* Fatal error */ 00679 DBUG_PRINT("info", ("msg_slang: %s", new_message->lang_short_name)); 00680 00681 /*skip space(s) and/or tabs after the lang */ 00682 while (*str == ' ' || *str == '\t' || *str == '\n') 00683 str++; 00684 00685 if (*str != '"') 00686 { 00687 fprintf(stderr, "Unexpected EOL"); 00688 DBUG_PRINT("info", ("str: %s", str)); 00689 DBUG_RETURN(0); 00690 } 00691 00692 /* reading the text */ 00693 start= str + 1; 00694 str= parse_text_line(start); 00695 00696 if (!(new_message->text= my_strndup(start, (uint) (str - start), 00697 MYF(MY_WME | MY_FAE)))) 00698 DBUG_RETURN(0); /* Fatal error */ 00699 DBUG_PRINT("info", ("msg_text: %s", new_message->text)); 00700 00701 DBUG_RETURN(new_message); 00702 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static char * parse_text_line | ( | char * | pos | ) | [static] |
Definition at line 906 of file comp_err.c.
References DBUG_ENTER, DBUG_RETURN, strmov(), and VOID.
Referenced by parse_message_string().
00907 { 00908 int i, nr; 00909 char *row= pos; 00910 DBUG_ENTER("parse_text_line"); 00911 00912 while (*pos) 00913 { 00914 if (*pos == '\\') 00915 { 00916 switch (*++pos) { 00917 case '\\': 00918 case '"': 00919 VOID(strmov(pos - 1, pos)); 00920 break; 00921 case 'n': 00922 pos[-1]= '\n'; 00923 VOID(strmov(pos, pos + 1)); 00924 break; 00925 default: 00926 if (*pos >= '0' && *pos < '8') 00927 { 00928 nr= 0; 00929 for (i= 0; i < 3 && (*pos >= '0' && *pos < '8'); i++) 00930 nr= nr * 8 + (*(pos++) - '0'); 00931 pos -= i; 00932 pos[-1]= nr; 00933 VOID(strmov(pos, pos + i)); 00934 } 00935 else if (*pos) 00936 VOID(strmov(pos - 1, pos)); /* Remove '\' */ 00937 } 00938 } 00939 else 00940 pos++; 00941 } 00942 while (pos > row + 1 && *pos != '"') 00943 pos--; 00944 *pos= 0; 00945 DBUG_RETURN(pos); 00946 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void print_version | ( | void | ) | [static] |
Definition at line 846 of file comp_err.c.
References DBUG_ENTER, DBUG_VOID_RETURN, and my_progname.
00847 { 00848 DBUG_ENTER("print_version"); 00849 printf("%s (Compile errormessage) Ver %s\n", my_progname, "2.0"); 00850 DBUG_VOID_RETURN; 00851 }
| static char * skip_delimiters | ( | char * | str | ) | [static] |
Definition at line 608 of file comp_err.c.
References DBUG_ENTER, and DBUG_RETURN.
Referenced by parse_charset_string(), parse_default_language(), parse_error_offset(), and parse_error_string().
00609 { 00610 DBUG_ENTER("skip_delimiters"); 00611 for (; 00612 *str == ' ' || *str == ',' || *str == '\t' || *str == '\r' || 00613 *str == '\n' || *str == '='; str++) 00614 ; 00615 DBUG_RETURN(str); 00616 }
Here is the caller graph for this function:

| static void usage | ( | void | ) | [static] |
Definition at line 3308 of file mysqltest.c.
03309 { 03310 print_version(); 03311 printf("MySQL AB, by Sasha, Matt, Monty & Jani\n"); 03312 printf("This software comes with ABSOLUTELY NO WARRANTY\n\n"); 03313 printf("Runs a test against the mysql server and compares output with a results file.\n\n"); 03314 printf("Usage: %s [OPTIONS] [database] < test_file\n", my_progname); 03315 my_print_help(my_long_options); 03316 printf(" --no-defaults Don't read default options from any options file.\n"); 03317 my_print_variables(my_long_options); 03318 }
char* DATADIRECTORY = (char*) "../sql/share/" [static] |
char* default_dbug_option = (char*) "d:t:O,/tmp/comp_err.trace" [static] |
Definition at line 45 of file comp_err.c.
| const char* default_language = "eng" |
Definition at line 58 of file comp_err.c.
Referenced by clean_up(), find_message(), and parse_input_file().
| const char* empty_string = "" |
Definition at line 52 of file comp_err.c.
Referenced by ndberror_classification_message(), ndberror_status_message(), and parse_error_string().
| int er_offset = 1000 |
Definition at line 59 of file comp_err.c.
Referenced by parse_error_string(), and parse_input_file().
Definition at line 48 of file comp_err.c.
char* HEADERFILE = (char*) "mysqld_error.h" [static] |
Definition at line 60 of file comp_err.c.
struct my_option my_long_options[] [static] |
Definition at line 95 of file comp_err.c.
char* NAMEFILE = (char*) "mysqld_ername.h" [static] |
char* OUTFILE = (char*) "errmsg.sys" [static] |
Definition at line 39 of file comp_err.c.
char* STATEFILE = (char*) "sql_state.h" [static] |
char* TXTFILE = (char*) "../sql/share/errmsg.txt" [static] |
1.4.7

