| 317 | |
| 318 | |
| 319 | static int create_sys_files(struct languages *lang_head, |
| 320 | struct errors *error_head, uint row_count) |
| 321 | { |
| 322 | FILE *to; |
| 323 | uint csnum= 0, length, i, row_nr; |
| 324 | uchar head[32]; |
| 325 | char outfile[FN_REFLEN], *outfile_end; |
| 326 | long start_pos; |
| 327 | struct message *tmp; |
| 328 | struct languages *tmp_lang; |
| 329 | struct errors *tmp_error; |
| 330 | |
| 331 | MY_STAT stat_info; |
| 332 | DBUG_ENTER("create_sys_files"); |
| 333 | |
| 334 | /* |
| 335 | going over all languages and assembling corresponding error messages |
| 336 | */ |
| 337 | for (tmp_lang= lang_head; tmp_lang; tmp_lang= tmp_lang->next_lang) |
| 338 | { |
| 339 | |
| 340 | /* setting charset name */ |
| 341 | if (!(csnum= get_charset_number(tmp_lang->charset, MY_CS_PRIMARY))) |
| 342 | { |
| 343 | fprintf(stderr, "Unknown charset '%s' in '%s'\n", tmp_lang->charset, |
| 344 | TXTFILE); |
| 345 | DBUG_RETURN(1); |
| 346 | } |
| 347 | |
| 348 | outfile_end= strxmov(outfile, DATADIRECTORY, |
| 349 | tmp_lang->lang_long_name, NullS); |
| 350 | if (!my_stat(outfile, &stat_info,MYF(0))) |
| 351 | { |
| 352 | if (my_mkdir(outfile, 0777,MYF(0)) < 0) |
| 353 | { |
| 354 | fprintf(stderr, "Can't create output directory for %s\n", |
| 355 | outfile); |
| 356 | DBUG_RETURN(1); |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | strxmov(outfile_end, FN_ROOTDIR, OUTFILE, NullS); |
| 361 | |
| 362 | if (!(to= my_fopen(outfile, O_WRONLY | FILE_BINARY, MYF(MY_WME)))) |
| 363 | DBUG_RETURN(1); |
| 364 | |
| 365 | /* 4 is for 4 bytes to store row position / error message */ |
| 366 | start_pos= (long) (HEADER_LENGTH + row_count * 4); |
| 367 | fseek(to, start_pos, 0); |
| 368 | row_nr= 0; |
| 369 | for (tmp_error= error_head; tmp_error; tmp_error= tmp_error->next_error) |
| 370 | { |
| 371 | /* dealing with messages */ |
| 372 | tmp= find_message(tmp_error, tmp_lang->lang_short_name, FALSE); |
| 373 | |
| 374 | if (!tmp) |
| 375 | { |
| 376 | fprintf(stderr, |
no test coverage detected