MCPcopy Create free account
hub / github.com/buke/quickjs-go / build_conv_table

Function build_conv_table

deps/quickjs/unicode_gen.c:1224–1322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1222}
1223
1224void build_conv_table(CCInfo *tab)
1225{
1226 int code, i, j;
1227 CCInfo *ci;
1228 TableEntry *te;
1229
1230 te = conv_table;
1231 for(code = 0; code <= CHARCODE_MAX; code++) {
1232 ci = &tab[code];
1233 if (ci->u_len == 0 && ci->l_len == 0 && ci->f_len == 0)
1234 continue;
1235 assert(te - conv_table < countof(conv_table));
1236 find_run_type(te, tab, code);
1237 assert(te->len <= 127);
1238 code += te->len - 1;
1239 te++;
1240 }
1241 conv_table_len = te - conv_table;
1242
1243 /* find the data index */
1244 for(i = 0; i < conv_table_len; i++) {
1245 int data_index;
1246 te = &conv_table[i];
1247
1248 switch(te->type) {
1249 case RUN_TYPE_U:
1250 case RUN_TYPE_L:
1251 case RUN_TYPE_UF:
1252 case RUN_TYPE_LF:
1253 data_index = find_data_index(conv_table, conv_table_len, te->data);
1254 if (data_index < 0) {
1255 switch(te->type) {
1256 case RUN_TYPE_U:
1257 te->type = RUN_TYPE_U_EXT;
1258 te->ext_len = 1;
1259 te->ext_data[0] = te->data;
1260 break;
1261 case RUN_TYPE_LF:
1262 te->type = RUN_TYPE_LF_EXT;
1263 te->ext_len = 1;
1264 te->ext_data[0] = te->data;
1265 break;
1266 default:
1267 printf("%05x: index not found\n", te->code);
1268 exit(1);
1269 }
1270 } else {
1271 te->data_index = data_index;
1272 }
1273 break;
1274 case RUN_TYPE_UF_D20:
1275 te->data_index = te->data;
1276 break;
1277 }
1278 }
1279
1280 /* find the data index for ext_data */
1281 for(i = 0; i < conv_table_len; i++) {

Callers 1

mainFunction · 0.85

Calls 6

find_run_typeFunction · 0.85
find_data_indexFunction · 0.85
exitFunction · 0.85
find_ext_data_indexFunction · 0.85
dump_case_conv_table1Function · 0.85
assertFunction · 0.50

Tested by

no test coverage detected