MCPcopy Create free account
hub / github.com/F-Stack/f-stack / do_composition

Function do_composition

freebsd/contrib/openzfs/module/unicode/u8_textprep.c:1053–1358  ·  view source on GitHub ↗

* The do_composition() reads the character string pointed by 's' and * do necessary canonical composition and then copy over the result back to * the 's'. * * The input argument 's' cannot contain more than 32 characters. */

Source from the content-addressed store, hash-verified

1051 * The input argument 's' cannot contain more than 32 characters.
1052 */
1053static size_t
1054do_composition(size_t uv, uchar_t *s, uchar_t *comb_class, uchar_t *start,
1055 uchar_t *disp, size_t last, uchar_t **os, uchar_t *oslast)
1056{
1057 uchar_t t[U8_STREAM_SAFE_TEXT_MAX + 1];
1058 uchar_t tc[U8_MB_CUR_MAX] = { '\0' };
1059 uint8_t saved_marks[U8_MAX_CHARS_A_SEQ];
1060 size_t saved_marks_count;
1061 uchar_t *p;
1062 uchar_t *saved_p;
1063 uchar_t *q;
1064 size_t i;
1065 size_t saved_i;
1066 size_t j;
1067 size_t k;
1068 size_t l;
1069 size_t C;
1070 size_t saved_l;
1071 size_t size;
1072 uint32_t u1;
1073 uint32_t u2;
1074 boolean_t match_not_found = B_TRUE;
1075
1076 /*
1077 * This should never happen unless the callers are doing some strange
1078 * and unexpected things.
1079 *
1080 * The "last" is the index pointing to the last character not last + 1.
1081 */
1082 if (last >= U8_MAX_CHARS_A_SEQ)
1083 last = U8_UPPER_LIMIT_IN_A_SEQ;
1084
1085 for (i = l = 0; i <= last; i++) {
1086 /*
1087 * The last or any non-Starters at the beginning, we don't
1088 * have any chance to do composition and so we just copy them
1089 * to the temporary buffer.
1090 */
1091 if (i >= last || comb_class[i] != U8_COMBINING_CLASS_STARTER) {
1092SAVE_THE_CHAR:
1093 p = s + start[i];
1094 size = disp[i];
1095 for (k = 0; k < size; k++)
1096 t[l++] = *p++;
1097 continue;
1098 }
1099
1100 /*
1101 * If this could be a start of Hangul Jamos, then, we try to
1102 * conjoin them.
1103 */
1104 if (s[start[i]] == U8_HANGUL_JAMO_1ST_BYTE) {
1105 U8_PUT_3BYTES_INTO_UTF32(u1, s[start[i]],
1106 s[start[i] + 1], s[start[i] + 2]);
1107 U8_PUT_3BYTES_INTO_UTF32(u2, s[start[i] + 3],
1108 s[start[i] + 4], s[start[i] + 5]);
1109
1110 if (U8_HANGUL_JAMO_L(u1) && U8_HANGUL_JAMO_V(u2)) {

Callers 1

collect_a_seqFunction · 0.85

Calls 2

find_composition_startFunction · 0.85
blockedFunction · 0.85

Tested by

no test coverage detected