MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxNormalizeComposition

Function fxNormalizeComposition

xs/sources/xsString.c:3513–3574  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3511}
3512
3513void fxNormalizeComposition(txMachine* the, txNormalizeBuffer* buffer)
3514{
3515 txInteger fromIndex = 1;
3516 txInteger toIndex = 1;
3517 if (buffer->count < 2)
3518 return;
3519 while (fromIndex < buffer->count) {
3520 txBoolean flag = 1;
3521 txInteger code = buffer->address[fromIndex];
3522 txU2* pairs;
3523 txInteger pairCount;
3524 txInteger pairFlag;
3525 if ((mxHangulVBase <= code) && (code < mxHangulVBase + mxHangulVCount))
3526 pairFlag = 3;
3527 else if ((mxHangulTBase <= code) && (code < mxHangulTBase + mxHangulTCount))
3528 pairFlag = 2;
3529 else
3530 pairFlag = fxGetCompositionPairs(code, &pairs, &pairCount);
3531 if (pairFlag) {
3532 txInteger order = fxGetCombinationOrder(code);
3533 txInteger starterIndex = toIndex - 1;
3534 while (starterIndex >= 0) {
3535 txInteger starterCode = buffer->address[starterIndex];
3536 txInteger starterOrder = fxGetCombinationOrder(starterCode);
3537 if (starterOrder == 0) {
3538 if (pairFlag == 3) {
3539 if ((mxHangulLBase <= starterCode) && (starterCode < mxHangulLBase + mxHangulLCount)) {
3540 starterCode -= mxHangulLBase;
3541 code -= mxHangulVBase;
3542 buffer->address[starterIndex] = mxHangulSBase + (starterCode * mxHangulNCount) + (code * mxHangulTCount);
3543 flag = 0;
3544 }
3545 }
3546 else if (pairFlag == 2) {
3547 if ((mxHangulSBase <= starterCode) && (starterCode < mxHangulSBase + mxHangulSCount)
3548 && ((starterCode - mxHangulSBase) % mxHangulTCount == 0)) {
3549 buffer->address[starterIndex] = starterCode + code - mxHangulTBase;
3550 flag = 0;
3551 }
3552 }
3553 else {
3554 starterCode = fxGetCompositionStarterCode(starterCode, pairs, pairCount);
3555 if (starterCode) {
3556 buffer->address[starterIndex] = starterCode;
3557 flag = 0;
3558 }
3559 }
3560 break;
3561 }
3562 if (starterOrder >= order)
3563 break;
3564 starterIndex--;
3565 }
3566 }
3567 if (flag) {
3568 buffer->address[toIndex] = code;
3569 toIndex++;
3570 }

Callers 1

fxNormalizeStringFunction · 0.85

Calls 3

fxGetCompositionPairsFunction · 0.85
fxGetCombinationOrderFunction · 0.85

Tested by

no test coverage detected