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

Function PiuCodeSearch

modules/piu/PC/Code/piuCode.c:672–716  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

670}
671
672void PiuCodeSearch(PiuCode* self, uint32_t size)
673{
674 xsMachine* the = (*self)->the;
675 xsStringValue string;
676 PiuTextBuffer* results = (*self)->results;
677 size_t former;
678 PiuCodeResult result;
679 PiuTextBufferClear(the, results);
680 if ((*self)->code) {
681 int32_t offset = 0;
682// int32_t itemCount = 0;
683 int32_t itemSize = 0;
684// itemCount = 0;
685 itemSize = sizeof(PiuCodeResultRecord);
686 for (;;) {
687 former = (*results)->current;
688 PiuTextBufferGrow(the, results, itemSize);
689 result = (PiuCodeResult)((char*)(*results) + former);
690 string = PiuToString((*self)->string);
691 result->count = fxMatchRegExp(NULL, (*self)->code, (*self)->data, string, offset);
692 if (result->count <= 0) {
693 break;
694 }
695 if ((*self)->data[0] == (*self)->data[1]) {
696 break;
697 }
698 offset = (*self)->data[1];
699 result->from = (*self)->data[0];
700 result->to = offset;
701 PiuCodeOffsetToColumnLine(self, result->from, &result->fromColumn, &result->fromLine);
702 PiuCodeOffsetToColumnLine(self, result->to, &result->toColumn, &result->toLine);
703 result->from = fxUTF8ToUnicodeOffset(string, result->from);
704 result->to = fxUTF8ToUnicodeOffset(string, result->to);
705// itemCount++;
706 }
707 (*self)->resultsSize = itemSize;
708 }
709 else {
710 former = (*results)->current;
711 PiuTextBufferGrow(the, results, sizeof(PiuCodeResultRecord));
712 result = (PiuCodeResult)((char*)(*results) + former);
713 result->count = -1;
714 (*self)->resultsSize = sizeof(PiuCodeResultRecord);
715 }
716}
717
718void PiuCodeSelect(PiuCode* self, int32_t selectionOffset, uint32_t selectionLength)
719{

Callers 3

PiuCodeDictionaryFunction · 0.85
PiuCode_set_stringFunction · 0.85
PiuCode_findFunction · 0.85

Calls 5

PiuTextBufferClearFunction · 0.85
PiuTextBufferGrowFunction · 0.85
fxMatchRegExpFunction · 0.85
fxUTF8ToUnicodeOffsetFunction · 0.85

Tested by

no test coverage detected