| 787 | } |
| 788 | |
| 789 | void parse_script_extensions(const char *filename) |
| 790 | { |
| 791 | FILE *f; |
| 792 | char line[4096], *p, buf[256], *q; |
| 793 | uint32_t c0, c1, c; |
| 794 | int i; |
| 795 | uint8_t script_ext[255]; |
| 796 | int script_ext_len; |
| 797 | |
| 798 | f = fopen(filename, "rb"); |
| 799 | if (!f) { |
| 800 | perror(filename); |
| 801 | exit(1); |
| 802 | } |
| 803 | |
| 804 | for(;;) { |
| 805 | if (!get_line(line, sizeof(line), f)) |
| 806 | break; |
| 807 | p = line; |
| 808 | while (isspace(*p)) |
| 809 | p++; |
| 810 | if (*p == '#' || *p == '@' || *p == '\0') |
| 811 | continue; |
| 812 | c0 = strtoul(p, (char **)&p, 16); |
| 813 | if (*p == '.' && p[1] == '.') { |
| 814 | p += 2; |
| 815 | c1 = strtoul(p, (char **)&p, 16); |
| 816 | } else { |
| 817 | c1 = c0; |
| 818 | } |
| 819 | assert(c1 <= CHARCODE_MAX); |
| 820 | p += strspn(p, " \t"); |
| 821 | script_ext_len = 0; |
| 822 | if (*p == ';') { |
| 823 | p++; |
| 824 | for(;;) { |
| 825 | p += strspn(p, " \t"); |
| 826 | q = buf; |
| 827 | while (*p != '\0' && *p != ' ' && *p != '#' && *p != '\t') { |
| 828 | if ((q - buf) < sizeof(buf) - 1) |
| 829 | *q++ = *p; |
| 830 | p++; |
| 831 | } |
| 832 | *q = '\0'; |
| 833 | if (buf[0] == '\0') |
| 834 | break; |
| 835 | i = find_name(unicode_script_short_name, |
| 836 | countof(unicode_script_short_name), buf); |
| 837 | if (i < 0) { |
| 838 | fprintf(stderr, "Script not found: %s\n", buf); |
| 839 | exit(1); |
| 840 | } |
| 841 | assert(script_ext_len < sizeof(script_ext)); |
| 842 | script_ext[script_ext_len++] = i; |
| 843 | } |
| 844 | for(c = c0; c <= c1; c++) { |
| 845 | CCInfo *ci = &unicode_db[c]; |
| 846 | ci->script_ext_len = script_ext_len; |