mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
Fixed but when generating .sys files
This commit is contained in:
parent
cdd4043117
commit
c0eebb831e
2 changed files with 45 additions and 24 deletions
|
@ -145,7 +145,8 @@ static struct message *find_message(struct errors *err, const char *lang,
|
|||
static int check_message_format(struct errors *err,
|
||||
const char* mess);
|
||||
static uint parse_input_file(const char *file_name, struct errors **top_error,
|
||||
struct languages **top_language);
|
||||
struct languages **top_language,
|
||||
uint *error_count);
|
||||
static int get_options(int *argc, char ***argv);
|
||||
static void print_version(void);
|
||||
static void usage(void);
|
||||
|
@ -162,14 +163,15 @@ 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);
|
||||
struct errors *error_head, uint max_error,
|
||||
uint error_count);
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
MY_INIT(argv[0]);
|
||||
{
|
||||
uint row_count;
|
||||
uint max_error, error_count;
|
||||
struct errors *error_head;
|
||||
struct languages *lang_head;
|
||||
DBUG_ENTER("main");
|
||||
|
@ -177,32 +179,39 @@ int main(int argc, char *argv[])
|
|||
charsets_dir= DEFAULT_CHARSET_DIR;
|
||||
my_umask_dir= 0777;
|
||||
if (get_options(&argc, &argv))
|
||||
DBUG_RETURN(1);
|
||||
if (!(row_count= parse_input_file(TXTFILE, &error_head, &lang_head)))
|
||||
goto err;
|
||||
if (!(max_error= parse_input_file(TXTFILE, &error_head, &lang_head,
|
||||
&error_count)))
|
||||
{
|
||||
fprintf(stderr, "Failed to parse input file %s\n", TXTFILE);
|
||||
DBUG_RETURN(1);
|
||||
goto err;
|
||||
}
|
||||
if (lang_head == NULL || error_head == NULL)
|
||||
{
|
||||
fprintf(stderr, "Failed to parse input file %s\n", TXTFILE);
|
||||
DBUG_RETURN(1);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (create_header_files(error_head))
|
||||
{
|
||||
fprintf(stderr, "Failed to create header files\n");
|
||||
DBUG_RETURN(1);
|
||||
goto err;
|
||||
}
|
||||
if (create_sys_files(lang_head, error_head, row_count))
|
||||
if (create_sys_files(lang_head, error_head, max_error, error_count))
|
||||
{
|
||||
fprintf(stderr, "Failed to create sys files\n");
|
||||
DBUG_RETURN(1);
|
||||
goto err;
|
||||
}
|
||||
clean_up(lang_head, error_head);
|
||||
DBUG_LEAVE; /* Can't use dbug after my_end() */
|
||||
my_end(info_flag ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
|
||||
return 0;
|
||||
|
||||
err:
|
||||
clean_up(lang_head, error_head);
|
||||
DBUG_LEAVE; /* Can't use dbug after my_end() */
|
||||
my_end(info_flag ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -313,7 +322,9 @@ 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)
|
||||
struct errors *error_head,
|
||||
uint max_error,
|
||||
uint error_count)
|
||||
{
|
||||
FILE *to;
|
||||
uint csnum= 0, length, i, row_nr;
|
||||
|
@ -358,8 +369,8 @@ static int create_sys_files(struct languages *lang_head,
|
|||
DBUG_RETURN(1);
|
||||
|
||||
/* 2 is for 2 bytes to store row position / error message */
|
||||
start_pos= (long) (HEADER_LENGTH + (row_count + section_count) * 2);
|
||||
fseek(to, start_pos, 0);
|
||||
start_pos= (long) (HEADER_LENGTH + (error_count + section_count) * 2);
|
||||
my_fseek(to, start_pos, 0, MYF(0));
|
||||
row_nr= 0;
|
||||
for (tmp_error= error_head; tmp_error; tmp_error= tmp_error->next_error)
|
||||
{
|
||||
|
@ -383,15 +394,18 @@ static int create_sys_files(struct languages *lang_head,
|
|||
row_nr++;
|
||||
}
|
||||
}
|
||||
DBUG_ASSERT(error_count == row_nr);
|
||||
|
||||
/* continue with header of the errmsg.sys file */
|
||||
length= ftell(to) - HEADER_LENGTH - (row_count + section_count) * 2;
|
||||
length= (my_ftell(to, MYF(0)) - HEADER_LENGTH -
|
||||
(error_count + section_count) * 2);
|
||||
bzero((uchar*) head, HEADER_LENGTH);
|
||||
bmove((uchar *) head, (uchar *) file_head, 4);
|
||||
bmove((uchar*) head, (uchar*) file_head, 4);
|
||||
head[4]= 1;
|
||||
int4store(head + 6, length);
|
||||
int2store(head + 10, row_count);
|
||||
int2store(head + 12, section_count);
|
||||
int2store(head + 10, max_error); /* Max error */
|
||||
int2store(head + 12, row_nr);
|
||||
int2store(head + 14, section_count);
|
||||
head[30]= csnum;
|
||||
|
||||
my_fseek(to, 0l, MY_SEEK_SET, MYF(0));
|
||||
|
@ -400,8 +414,8 @@ static int create_sys_files(struct languages *lang_head,
|
|||
MYF(MY_WME | MY_FNABP)))
|
||||
goto err;
|
||||
|
||||
file_pos[row_count]= (ftell(to) - start_pos);
|
||||
for (i= 0; i < row_count; i++)
|
||||
file_pos[row_nr]= (ftell(to) - start_pos);
|
||||
for (i= 0; i < row_nr; i++)
|
||||
{
|
||||
/* Store length of each string */
|
||||
int2store(head, file_pos[i+1] - file_pos[i]);
|
||||
|
@ -459,18 +473,19 @@ static void clean_up(struct languages *lang_head, struct errors *error_head)
|
|||
|
||||
|
||||
static uint parse_input_file(const char *file_name, struct errors **top_error,
|
||||
struct languages **top_lang)
|
||||
struct languages **top_lang, uint *error_count)
|
||||
{
|
||||
FILE *file;
|
||||
char *str, buff[1000];
|
||||
struct errors *current_error= 0, **tail_error= top_error;
|
||||
struct message current_message;
|
||||
uint rcount= 0;
|
||||
uint rcount= 0, skiped_errors= 0;
|
||||
my_bool er_offset_found= 0;
|
||||
DBUG_ENTER("parse_input_file");
|
||||
|
||||
*top_error= 0;
|
||||
*top_lang= 0;
|
||||
*error_count= 0;
|
||||
section_start= er_offset;
|
||||
section_count= 0;
|
||||
|
||||
|
@ -528,6 +543,7 @@ static uint parse_input_file(const char *file_name, struct errors **top_error,
|
|||
}
|
||||
for ( ; er_offset + rcount < tmp_er_offset ; rcount++)
|
||||
{
|
||||
skiped_errors+= skip != 0;
|
||||
current_error= generate_empty_message(er_offset + rcount, skip);
|
||||
*tail_error= current_error;
|
||||
tail_error= ¤t_error->next_error;
|
||||
|
@ -603,6 +619,7 @@ static uint parse_input_file(const char *file_name, struct errors **top_error,
|
|||
int2store(section_header + section_count*2,
|
||||
er_offset + rcount - section_start);
|
||||
section_count++;
|
||||
*error_count= rcount - skiped_errors;
|
||||
|
||||
*tail_error= 0; /* Mark end of list */
|
||||
|
||||
|
@ -1119,10 +1136,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__ ((unused)),
|
|||
switch (optid) {
|
||||
case 'V':
|
||||
print_version();
|
||||
my_end(0);
|
||||
exit(0);
|
||||
break;
|
||||
case '?':
|
||||
usage();
|
||||
my_end(0);
|
||||
exit(0);
|
||||
break;
|
||||
case '#':
|
||||
|
|
|
@ -176,6 +176,7 @@ static bool check_error_mesg(const char *file_name, const char **errmsg)
|
|||
struct st_msg_file
|
||||
{
|
||||
uint sections;
|
||||
uint max_error;
|
||||
uint errors;
|
||||
size_t text_length;
|
||||
};
|
||||
|
@ -224,10 +225,11 @@ static File open_error_msg_file(const char *file_name, const char *language,
|
|||
goto err; /* purecov: inspected */
|
||||
|
||||
ret->text_length= uint4korr(head+6);
|
||||
ret->errors= uint2korr(head+10);
|
||||
ret->sections= uint2korr(head+12);
|
||||
ret->max_error= uint2korr(head+10);
|
||||
ret->errors= uint2korr(head+12);
|
||||
ret->sections= uint2korr(head+14);
|
||||
|
||||
if (ret->errors < error_messages || ret->sections != MAX_ERROR_RANGES)
|
||||
if (ret->max_error < error_messages || ret->sections != MAX_ERROR_RANGES)
|
||||
{
|
||||
sql_print_error("\
|
||||
Error message file '%s' had only %d error messages, but it should contain at least %d error messages.\nCheck that the above file is the right version for this program!",
|
||||
|
|
Loading…
Reference in a new issue