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

Function fxFindCharacter

xs/sources/xsre.c:2609–2651  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2607// MATCH
2608
2609txInteger fxFindCharacter(txString input, txInteger offset, txInteger direction, txInteger flags)
2610{
2611 txU1* p = (txU1*)input + offset;
2612 txU1 c;
2613#if mxCESU8
2614 if (flags & XS_REGEXP_UV) {
2615 txInteger character;
2616 if (direction > 0) {
2617 p = (txU1*)mxStringByteDecode((txString)p, &character);
2618 }
2619 else if (offset > 0) {
2620 p--;
2621 while ((c = c_read8(p))) {
2622 if ((c & 0xC0) != 0x80)
2623 break;
2624 p--;
2625 }
2626 fxUTF8Decode((txString)p, &character);
2627 if ((0x0000DC00 <= character) && (character <= 0x0000DFFF)) {
2628 txU1* q = p - 1;
2629 while ((c = c_read8(q))) {
2630 if ((c & 0xC0) != 0x80)
2631 break;
2632 q--;
2633 }
2634 fxUTF8Decode((txString)q, &character);
2635 if ((0x0000D800 <= character) && (character <= 0x0000DBFF))
2636 p = q;
2637 }
2638 }
2639 }
2640 else
2641#endif
2642 {
2643 p += direction;
2644 while ((c = c_read8(p))) {
2645 if ((c & 0xC0) != 0x80)
2646 break;
2647 p += direction;
2648 }
2649 }
2650 return mxPtrDiff(p - (txU1*)input);
2651}
2652
2653txInteger fxGetCharacter(txString input, txInteger offset, txInteger flags)
2654{

Callers 2

fxMatchRegExpFunction · 0.85
fxFinalSigmaToLowerFunction · 0.85

Calls 1

fxUTF8DecodeFunction · 0.85

Tested by

no test coverage detected