| 483 | } |
| 484 | |
| 485 | void parse_case_folding(CCInfo *tab, const char *filename) |
| 486 | { |
| 487 | FILE *f; |
| 488 | char line[1024]; |
| 489 | const char *p; |
| 490 | int code, status; |
| 491 | CCInfo *ci; |
| 492 | |
| 493 | f = fopen(filename, "rb"); |
| 494 | if (!f) { |
| 495 | perror(filename); |
| 496 | exit(1); |
| 497 | } |
| 498 | |
| 499 | for(;;) { |
| 500 | if (!get_line(line, sizeof(line), f)) |
| 501 | break; |
| 502 | p = line; |
| 503 | while (isspace(*p)) |
| 504 | p++; |
| 505 | if (*p == '#') |
| 506 | continue; |
| 507 | |
| 508 | p = get_field(line, 0); |
| 509 | if (!p) |
| 510 | continue; |
| 511 | code = strtoul(p, NULL, 16); |
| 512 | assert(code <= CHARCODE_MAX); |
| 513 | ci = &tab[code]; |
| 514 | |
| 515 | p = get_field(line, 1); |
| 516 | if (!p) |
| 517 | continue; |
| 518 | /* locale dependent casing */ |
| 519 | while (isspace(*p)) |
| 520 | p++; |
| 521 | status = *p; |
| 522 | if (status != 'C' && status != 'S' && status != 'F') |
| 523 | continue; |
| 524 | |
| 525 | p = get_field(line, 2); |
| 526 | assert(p != NULL); |
| 527 | if (status == 'S') { |
| 528 | /* we always select the simple case folding and assume it |
| 529 | * comes after the full case folding case */ |
| 530 | assert(ci->f_len >= 2); |
| 531 | ci->f_len = 0; |
| 532 | } else { |
| 533 | assert(ci->f_len == 0); |
| 534 | } |
| 535 | for(;;) { |
| 536 | while (isspace(*p)) |
| 537 | p++; |
| 538 | if (*p == ';') |
| 539 | break; |
| 540 | assert(ci->l_len < CC_LEN_MAX); |
| 541 | ci->f_data[ci->f_len++] = strtoul(p, (char **)&p, 16); |
| 542 | } |