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

Function fxNormalizeDecomposition

xs/sources/xsString.c:3576–3621  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3574}
3575
3576void fxNormalizeDecomposition(txMachine* the, txNormalizeBuffer* buffer, txInteger* source, txInteger c, txFlag compatible)
3577{
3578 txInteger i;
3579 for (i = 0; i < c; i++) {
3580 txInteger code = source[i];
3581 if ((mxHangulSBase <= code) && (code < mxHangulSBase + mxHangulSCount)) {
3582 txInteger sIndex = code - mxHangulSBase;
3583 txInteger lIndex = sIndex / mxHangulNCount;
3584 txInteger vIndex = (sIndex % mxHangulNCount) / mxHangulTCount;
3585 txInteger tIndex = sIndex % mxHangulTCount;
3586 fxInsertDecomposition(the, buffer, buffer->count, mxHangulLBase + lIndex);
3587 fxInsertDecomposition(the, buffer, buffer->count, mxHangulVBase + vIndex);
3588 if (tIndex > 0)
3589 fxInsertDecomposition(the, buffer, buffer->count, mxHangulTBase + tIndex);
3590 buffer->starterIndex = buffer->count;
3591 }
3592 else {
3593 txInteger decompositionBuffer[mxDecompositionBufferCount];
3594 txInteger decompositionCount = fxGetDecompositionBuffer(code, decompositionBuffer, compatible);
3595 if (decompositionCount == 0) {
3596 txInteger order = fxGetCombinationOrder(code);
3597 if (order == 0) {
3598 fxInsertDecomposition(the, buffer, buffer->count, code);
3599 buffer->starterIndex = buffer->count;
3600 }
3601 else {
3602 txInteger bufferIndex = buffer->count - 1;
3603 txInteger starterIndex = buffer->starterIndex - 1;
3604 while (bufferIndex > starterIndex) {
3605 txInteger starterCode = buffer->address[bufferIndex];
3606 txInteger starterOrder = fxGetCombinationOrder(starterCode);
3607 if (starterOrder <= order) {
3608 fxInsertDecomposition(the, buffer, bufferIndex + 1, code);
3609 break;
3610 }
3611 bufferIndex--;
3612 }
3613 if (bufferIndex == starterIndex)
3614 fxInsertDecomposition(the, buffer, bufferIndex + 1, code);
3615 }
3616 }
3617 else
3618 fxNormalizeDecomposition(the, buffer, decompositionBuffer, decompositionCount, compatible);
3619 }
3620 }
3621}
3622
3623void fxNormalizeString(txMachine* the, txSlot* string, txFlag form)
3624{

Callers 1

fxNormalizeStringFunction · 0.85

Calls 3

fxInsertDecompositionFunction · 0.85
fxGetDecompositionBufferFunction · 0.85
fxGetCombinationOrderFunction · 0.85

Tested by

no test coverage detected