| 483 | |
| 484 | |
| 485 | static void |
| 486 | print_contraction(MY_UCA *uca, MY_UCA_CONTRACTION *c, size_t level) |
| 487 | { |
| 488 | size_t ch; |
| 489 | uint16 weight[MY_UCA_MAXWEIGHT_TO_DUMP + 1]; |
| 490 | int optimize= 0; |
| 491 | |
| 492 | if (c) |
| 493 | { |
| 494 | normalize_weight(&c->item, level, |
| 495 | weight, sizeof(weight)/sizeof(weight[0])); |
| 496 | |
| 497 | if (uca->optimize_contractions) |
| 498 | { |
| 499 | /* |
| 500 | Some contraction can be optimized away on certain levels. |
| 501 | For example, in Unicode-6.0: |
| 502 | |
| 503 | 0E40 0E01 ; [.2395.0020.0002.0E01][.23CF.0020.001F.0E40] # <THAI CHARACTER SARA E, THAI CHARACTER KO KAI> |
| 504 | |
| 505 | Its part weights are: |
| 506 | |
| 507 | 0E40 ; [.23CF.0020.0002.0E40] # THAI CHARACTER SARA E |
| 508 | 0E01 ; [.2395.0020.0002.0E01] # THAI CHARACTER KO KAI |
| 509 | |
| 510 | On the secondary level weights for the contraction |
| 511 | and for the two characters in a sequence are: 0020-0020. |
| 512 | |
| 513 | So "0E40 0E01" can be optimized away of the secondary level. |
| 514 | |
| 515 | This optimization is OFF by default, as it's better to optimize |
| 516 | this at collation initialization time rather than at dump time, |
| 517 | to preserve all available DUCET data. |
| 518 | |
| 519 | Also, this does not seem to ever happen on the primary level, |
| 520 | so this optimization will not bring any serious performance |
| 521 | improvement. |
| 522 | */ |
| 523 | size_t i; |
| 524 | uint16 sweight[MY_UCA_MAXWEIGHT_TO_DUMP*MY_UCA_MAX_CONTRACTION + 1], *sw; |
| 525 | |
| 526 | /* Concatenate weight arrays for the contraction parts */ |
| 527 | for (sw= sweight, i= 0; c->ch[i]; i++) |
| 528 | { |
| 529 | MY_UCA_ITEM *item= &uca->item[c->ch[i]]; |
| 530 | sw+= normalize_weight(item, level, sw, MY_UCA_MAXWEIGHT_TO_DUMP); |
| 531 | } |
| 532 | |
| 533 | if (sw - sweight < MY_UCA_MAXWEIGHT_TO_DUMP && |
| 534 | !weight_cmp(sweight, weight, MY_UCA_MAXWEIGHT_TO_DUMP)) |
| 535 | { |
| 536 | if (uca->debug) |
| 537 | fprintf(stderr, "Equal[%d]: %04X [%04X-%04X-%04X] == {%04X,%04X,%04X} [%04X-%04X-%04X]\n", |
| 538 | level, |
| 539 | c->ch[0], sweight[0], sweight[1], sweight[2], |
| 540 | c->ch[0], c->ch[1], c->ch[2], |
| 541 | weight[0], weight[1], weight[2]); |
| 542 | optimize= 1; |
no test coverage detected