processes hyphenation between subtokens if any
| 22 | |
| 23 | //! processes hyphenation between subtokens if any |
| 24 | inline void ProcessHyphenation(wchar16* buffer, const wchar16* entry, TCharSpan*& desttok, const TCharSpan* srctok, size_t& destpos, size_t& srcpos) { |
| 25 | // Check if the space contains hyphenation, and copy the separator |
| 26 | if (desttok->Hyphen == HYPHEN_ORDINARY) { |
| 27 | if (desttok->Type == TOKEN_WORD && srctok->Type == TOKEN_WORD) { |
| 28 | // glue two adjacent tokens if both are TOKEN_WORD |
| 29 | srcpos = srctok->Pos; |
| 30 | GlueTokens(desttok, srctok); |
| 31 | } else { |
| 32 | // copy delimiter only - remove all following whitespace characters, for example: "sepa- \n rator" (see nlptok.rl, hyphenation/nlfasblank) |
| 33 | wchar16* const dest = buffer + destpos; |
| 34 | const wchar16* const src = entry + srcpos; // srcpos - the beginning of source delimiter |
| 35 | *dest = *src; |
| 36 | desttok->TokenDelim = TOKDELIM_MINUS; |
| 37 | ++destpos; |
| 38 | srcpos = srctok->Pos; // keep it before CopyToken() |
| 39 | CopyToken(++desttok, srctok, destpos); |
| 40 | } |
| 41 | } else if (desttok->Hyphen == HYPHEN_SOFT) { |
| 42 | if (desttok->Type == srctok->Type) { |
| 43 | // glue two adjacent tokens if both have the same type |
| 44 | srcpos = srctok->Pos; |
| 45 | GlueTokens(desttok, srctok); |
| 46 | } else { |
| 47 | // delimiter isn't copied |
| 48 | srcpos = srctok->Pos; // keep it before CopyToken() |
| 49 | CopyToken(++desttok, srctok, destpos); |
| 50 | } |
| 51 | } else { |
| 52 | Y_ASSERT(desttok->Hyphen == HYPHEN_NONE); // HYPHEN_HARD isn't processed yet |
| 53 | Y_ASSERT(srctok->Pos >= srcpos); |
| 54 | if (srctok->Pos > srcpos) { |
| 55 | // copy the delimiter and create the next token |
| 56 | const size_t seplen = srctok->Pos - srcpos; // srcpos - the beginning of source delimiter |
| 57 | |
| 58 | // copy suffix with delimiter |
| 59 | std::char_traits<wchar16>::copy(buffer + destpos, entry + srcpos, seplen); |
| 60 | destpos += seplen; |
| 61 | |
| 62 | srcpos = srctok->Pos; // keep it before CopyToken() |
| 63 | } |
| 64 | CopyToken(++desttok, srctok, destpos); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | //! @param len length of text to be copied (it can include suffix length) |
| 69 | inline void CopyTokenText(wchar16* buffer, const wchar16* entry, size_t len, size_t& destpos, size_t& srcpos) { |
no test coverage detected