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

Function PiuCode_findAgain

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

Source from the content-addressed store, hash-verified

1052}
1053
1054void PiuCode_findAgain(xsMachine *the)
1055{
1056 PiuCode* self = PIU(Code, xsThis);
1057 PiuTextBuffer* results = (*self)->results;
1058 uint32_t argc = xsToUnsigned(xsArgc);
1059 xsIntegerValue direction = 1;
1060 int32_t count, index;
1061 PiuCodeResult result, wrap;
1062 if (argc > 0)
1063 direction = xsToInteger(xsArg(0));
1064 count = (((*results)->current - sizeof(PiuTextBufferRecord)) / (*self)->resultsSize) - 1;
1065 if (count) {
1066 xsResult = xsTrue;
1067 if (direction > 0) {
1068 result = wrap = (PiuCodeResult)((char*)(*results) + sizeof(PiuTextBufferRecord));
1069 for (index = 0; index < count; index++) {
1070 if ((*self)->to <= result->from) {
1071 PiuCodeSelect(self, result->from, result->to - result->from);
1072 return;
1073 }
1074 result = (PiuCodeResult)(((char*)result) + (*self)->resultsSize);
1075 }
1076 }
1077 else {
1078 result = wrap = (PiuCodeResult)((char*)(*results) + (*results)->current - (*self)->resultsSize - (*self)->resultsSize);
1079 for (index = count - 1; index >= 0; index--) {
1080 if ((*self)->from >= result->to) {
1081 PiuCodeSelect(self, result->from, result->to - result->from);
1082 return;
1083 }
1084 result = (PiuCodeResult)(((char*)result) - (*self)->resultsSize);
1085 }
1086 }
1087 PiuCodeSelect(self, wrap->from, wrap->to - wrap->from);
1088 }
1089 else
1090 xsResult = xsFalse;
1091}
1092
1093void PiuCode_findBlock(xsMachine *the)
1094{

Callers

nothing calls this directly

Calls 1

PiuCodeSelectFunction · 0.85

Tested by

no test coverage detected