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

Function PiuCodeFindWordBreak

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

Source from the content-addressed store, hash-verified

445}
446
447int32_t PiuCodeFindWordBreak(PiuCode* self, int32_t result, int32_t direction)
448{
449 if ((direction < 0) && (result == 0))
450 result = 0;
451 else if ((direction > 0) && (result >= (int32_t)(*self)->length))
452 result = (*self)->length;
453 else {
454 xsMachine* the = (*self)->the;
455 xsStringValue string = PiuToString((*self)->string);
456 int32_t character;
457 int32_t classification;
458 if (direction > 0)
459 string += fxUnicodeToUTF8Offset(string, result);
460 else
461 string += fxUnicodeToUTF8Offset(string, result - 1);
462 fxUTF8Decode(string, &character);
463 classification = PiuCodeClassifyCharacter(character);
464 do {
465 int32_t advance = fxUTF8Advance(string, 0, direction);
466 if (0 == advance)
467 break;
468 string += advance;
469 result += direction;
470 fxUTF8Decode(string, &character);
471 } while (PiuCodeClassifyCharacter(character) == classification);
472 }
473 return result;
474}
475
476void PiuCodeFormat(PiuCode* self)
477{

Callers 1

PiuCode_findWordBreakFunction · 0.85

Calls 4

fxUnicodeToUTF8OffsetFunction · 0.85
fxUTF8DecodeFunction · 0.85
PiuCodeClassifyCharacterFunction · 0.85
fxUTF8AdvanceFunction · 0.85

Tested by

no test coverage detected