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

Function parse_case_folding

deps/quickjs/unicode_gen.c:485–546  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

483}
484
485void 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 }

Callers 1

mainFunction · 0.85

Calls 4

exitFunction · 0.85
get_lineFunction · 0.85
get_fieldFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected