| 445 | } |
| 446 | |
| 447 | int32_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 | |
| 476 | void PiuCodeFormat(PiuCode* self) |
| 477 | { |
no test coverage detected