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

Function fxNormalizeString

xs/sources/xsString.c:3623–3671  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3621}
3622
3623void fxNormalizeString(txMachine* the, txSlot* string, txFlag form)
3624{
3625 txNormalizeBuffer _buffer;
3626 txNormalizeBuffer* buffer = &_buffer;
3627 txInteger source[mxSourceBufferCount];
3628 txString p;
3629
3630 mxPushUndefined();
3631 buffer->slot = the->stack;
3632 buffer->address = fxArrayBuffer(the, the->stack, C_NULL, 64, 0x7FFFFFFF);
3633 buffer->count = 0;
3634 buffer->starterIndex = 0;
3635
3636 p = string->value.string;
3637 for (;;) {
3638 txInteger* sourceAddress = source;
3639 txInteger sourceIndex = 0;
3640 while (sourceIndex < mxSourceBufferCount) {
3641 p = mxStringByteDecode(p, sourceAddress);
3642 if (*sourceAddress == C_EOF)
3643 break;
3644 sourceAddress++;
3645 sourceIndex++;
3646 }
3647 if (sourceIndex) {
3648 txInteger offset = mxPtrDiff(p - string->value.string);
3649 fxNormalizeDecomposition(the, buffer, source, sourceIndex, form & 1);
3650 p = string->value.string + offset;
3651 }
3652 if (sourceIndex < mxSourceBufferCount)
3653 break;
3654 }
3655 if (form & 2)
3656 fxNormalizeComposition(the, buffer);
3657 if (buffer->count) {
3658 txInteger resultIndex;
3659 txInteger stringLength = 0;
3660 for (resultIndex = 0; resultIndex < buffer->count; resultIndex++)
3661 stringLength += mxStringByteLength(buffer->address[resultIndex]);
3662 stringLength++;
3663 p = string->value.string = fxNewChunk(the, stringLength);
3664 buffer->address = fxToArrayBuffer(the, the->stack);
3665 for (resultIndex = 0; resultIndex < buffer->count; resultIndex++)
3666 p = mxStringByteEncode(p, buffer->address[resultIndex]);
3667 *p = 0;
3668 }
3669
3670 mxPop();
3671}
3672
3673#endif

Callers 1

Calls 5

fxArrayBufferFunction · 0.85
fxNormalizeDecompositionFunction · 0.85
fxNormalizeCompositionFunction · 0.85
fxNewChunkFunction · 0.85
fxToArrayBufferFunction · 0.85

Tested by

no test coverage detected