| 62 | |
| 63 | |
| 64 | static int load_uca_file(MY_UCA *uca, |
| 65 | size_t maxchar, int *pageloaded) |
| 66 | { |
| 67 | char str[512]; |
| 68 | size_t lineno, out_of_range_chars= 0; |
| 69 | char *weights[MY_UCA_MAXWEIGHT_TO_PARSE]; |
| 70 | |
| 71 | for (lineno= 0; fgets(str, sizeof(str), stdin); lineno++) |
| 72 | { |
| 73 | char *comment; |
| 74 | char *weight; |
| 75 | char *s, *ch[MY_UCA_MAX_CONTRACTION]; |
| 76 | size_t codenum, i, code; |
| 77 | MY_UCA_ITEM *item= NULL; |
| 78 | |
| 79 | |
| 80 | /* Skip comment lines */ |
| 81 | if (*str== '\r' || *str == '\n' || *str == '#') |
| 82 | continue; |
| 83 | |
| 84 | /* Detect version */ |
| 85 | if (*str == '@' && !strncmp(str, "@version ", 9)) |
| 86 | { |
| 87 | const char *value; |
| 88 | if (strtok(str, " \r\n\t") && (value= strtok(NULL, " \r\n\t"))) |
| 89 | snprintf(uca->version, MY_UCA_VERSION_SIZE, value); |
| 90 | continue; |
| 91 | } |
| 92 | |
| 93 | /* Skip big characters */ |
| 94 | if ((code= strtol(str,NULL,16)) > maxchar) |
| 95 | { |
| 96 | out_of_range_chars++; |
| 97 | continue; |
| 98 | } |
| 99 | |
| 100 | |
| 101 | if ((comment= strchr(str,'#'))) |
| 102 | { |
| 103 | *comment++= '\0'; |
| 104 | for ( ; *comment == ' '; comment++); |
| 105 | } |
| 106 | else |
| 107 | { |
| 108 | fprintf(stderr, "Warning: could not parse line #%d:\n'%s'\n", |
| 109 | lineno, str); |
| 110 | continue; |
| 111 | } |
| 112 | |
| 113 | |
| 114 | if ((weight= strchr(str,';'))) |
| 115 | { |
| 116 | *weight++= '\0'; |
| 117 | for ( ; *weight==' '; weight++); |
| 118 | } |
| 119 | else |
| 120 | { |
| 121 | fprintf(stderr, "Warning: could not parse line #%d:\n%s\n", lineno, str); |