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

Function parse_unicode_data

deps/quickjs/unicode_gen.c:286–407  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284}
285
286void parse_unicode_data(const char *filename)
287{
288 FILE *f;
289 char line[1024];
290 char buf1[256];
291 const char *p;
292 int code, lc, uc, last_code;
293 CCInfo *ci, *tab = unicode_db;
294
295 f = fopen(filename, "rb");
296 if (!f) {
297 perror(filename);
298 exit(1);
299 }
300
301 last_code = 0;
302 for(;;) {
303 if (!get_line(line, sizeof(line), f))
304 break;
305 p = line;
306 while (isspace(*p))
307 p++;
308 if (*p == '#')
309 continue;
310
311 p = get_field(line, 0);
312 if (!p)
313 continue;
314 code = strtoul(p, NULL, 16);
315 lc = 0;
316 uc = 0;
317
318 p = get_field(line, 12);
319 if (p && *p != ';') {
320 uc = strtoul(p, NULL, 16);
321 }
322
323 p = get_field(line, 13);
324 if (p && *p != ';') {
325 lc = strtoul(p, NULL, 16);
326 }
327 ci = &tab[code];
328 if (uc > 0 || lc > 0) {
329 assert(code <= CHARCODE_MAX);
330 if (uc > 0) {
331 assert(ci->u_len == 0);
332 ci->u_len = 1;
333 ci->u_data[0] = uc;
334 }
335 if (lc > 0) {
336 assert(ci->l_len == 0);
337 ci->l_len = 1;
338 ci->l_data[0] = lc;
339 }
340 }
341
342 {
343 int i;

Callers 1

mainFunction · 0.85

Calls 8

exitFunction · 0.85
get_lineFunction · 0.85
get_fieldFunction · 0.85
get_field_bufFunction · 0.85
find_nameFunction · 0.85
add_charFunction · 0.85
set_propFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected