MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / print_one_page

Function print_one_page

strings/uca-dump.c:398–464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

396
397
398static void
399print_one_page(MY_UCA *uca, size_t level,
400 size_t page, size_t maxnum)
401{
402 size_t offs, mchars, nchars= 0, chars_per_line;
403
404 printf("uint16 %s[]= { /* %04X (%d weights per char) */\n",
405 page_name(uca, page, level), page * MY_UCA_NCHARS, maxnum);
406
407 /* Calculate how many wights to print per line */
408 switch (maxnum)
409 {
410 case 0: mchars= 8; chars_per_line= 8; break;
411 case 1: mchars= 8; chars_per_line= 8; break;
412 case 2: mchars= 8; chars_per_line= 4; break;
413 case 3: mchars= 9; chars_per_line= 3; break;
414 case 4: mchars= 8; chars_per_line= 2; break;
415 default:
416 mchars= uca->item[page * MY_UCA_NCHARS + offs].num;
417 chars_per_line= 1;
418 }
419
420
421 /* Print the page */
422 for (offs=0; offs < MY_UCA_NCHARS; offs++)
423 {
424 uint16 weight[MY_UCA_MAXWEIGHT_TO_DUMP + 1];
425 size_t num, i, code= page * MY_UCA_NCHARS + offs;
426 MY_UCA_ITEM *item= &uca->item[code];
427
428 normalize_weight(item, level, weight, sizeof(weight)/sizeof(weight[0]));
429
430 /* Print weights */
431 for (i= 0; i < maxnum; i++)
432 {
433 int tmp= weight[i];
434
435 printf("0x%04X", tmp);
436
437 if (tmp > 0xFFFF || tmp < 0)
438 {
439 fprintf(stderr,
440 "Error: Too big weight for code point %04X level %d: %08X\n",
441 code, level, tmp);
442 exit(1);
443 }
444
445 if ((offs + 1 != MY_UCA_NCHARS) || (i + 1 != maxnum))
446 printf(",");
447 else
448 printf(" ");
449 nchars++;
450 }
451
452 if (nchars >=mchars)
453 {
454 /* Print "\n" with a comment telling the first code on this line. */
455 printf(" /* %04X */\n", (code + 1) - chars_per_line);

Callers 1

mainFunction · 0.85

Calls 2

page_nameFunction · 0.85
normalize_weightFunction · 0.85

Tested by

no test coverage detected