Debian Codegraph @

lib/highlighter.c

raw symbols SCIP
1 /*
2 Copyright (C) 2018 Brazil
3 Copyright (C) 2018-2024 Sutou Kouhei <[email protected]>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #include "grn.h"cxx . . $ `<file>/lib/grn.h`/
21 #include "grn_token_cursor.h"cxx . . $ `<file>/lib/grn_token_cursor.h`/
22
23 #include "grn_pat.h"cxx . . $ `<file>/lib/grn_pat.h`/
24 #include "grn_str.h"cxx . . $ `<file>/lib/grn_str.h`/
25
26 #define GRN_HIGHLIGHTER_DEFAULT_OPEN_TAGcxx . . $ `lib/highlighter.c:26:9`! "<span class=\"keyword\">"
27 #define GRN_HIGHLIGHTER_DEFAULT_CLOSE_TAGcxx . . $ `lib/highlighter.c:27:9`! "</span>"
28
29 typedef structcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0# {
30 grn_idcxx . . $ grn_id# chunk_idcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#chunk_id.;
31 uint64_tcxx . . $ uint64_t# offsetcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#offset.;
32 uint32_tcxx . . $ uint32_t# lengthcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#length.;
33 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! have_overlapcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#have_overlap.;
34 uint32_tcxx . . $ uint32_t# first_character_lengthcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#first_character_length.;
35 } grn_highlighter_locationcxx . . $ grn_highlighter_location#;
36
37 static int
38 grn_highlighter_location_comparecxx . . $ grn_highlighter_location_compare(9148c8c3ff42c9d8).(const void *data1, const void *data2)
39 {
40 const grn_highlighter_locationcxx . . $ grn_highlighter_location# *location1 = data1;
41 const grn_highlighter_locationcxx . . $ grn_highlighter_location# *location2 = data2;
42
43 if (location1->offsetcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#offset. == location2->offsetcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#offset.) {
44 return (int)(location1->lengthcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#length. - location2->lengthcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#length.);
45 } else {
46 return (int)(location1->offsetcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#offset. - location2->offsetcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#offset.);
47 }
48 }
49
50 struct _grn_highlightercxx . . $ _grn_highlighter# {
51 grn_obj_headercxx . . $ grn_obj_header# headercxx . . $ _grn_highlighter#header.;
52
53 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! is_html_modecxx . . $ _grn_highlighter#is_html_mode.;
54 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! need_preparedcxx . . $ _grn_highlighter#need_prepared.;
55 grn_objcxx . . $ grn_obj# raw_keywordscxx . . $ _grn_highlighter#raw_keywords.;
56
57 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! is_sequential_class_tag_modecxx . . $ _grn_highlighter#is_sequential_class_tag_mode.;
58 structcxx . . $ _grn_highlighter#$anonymous_type_1# {
59 grn_objcxx . . $ grn_obj# opencxx . . $ _grn_highlighter#$anonymous_type_1#open.;
60 grn_objcxx . . $ grn_obj# closecxx . . $ _grn_highlighter#$anonymous_type_1#close.;
61 } sequential_class_tagcxx . . $ _grn_highlighter#sequential_class_tag.;
62
63 structcxx . . $ _grn_highlighter#$anonymous_type_2# {
64 grn_objcxx . . $ grn_obj# opencxx . . $ _grn_highlighter#$anonymous_type_2#open.;
65 grn_objcxx . . $ grn_obj# closecxx . . $ _grn_highlighter#$anonymous_type_2#close.;
66 } default_tagcxx . . $ _grn_highlighter#default_tag.;
67
68 grn_objcxx . . $ grn_obj# open_tagscxx . . $ _grn_highlighter#open_tags.;
69 grn_objcxx . . $ grn_obj# close_tagscxx . . $ _grn_highlighter#close_tags.;
70 size_t n_tagscxx . . $ _grn_highlighter#n_tags.;
71
72 /* For lexicon mode */
73 structcxx . . $ _grn_highlighter#$anonymous_type_3# {
74 grn_objcxx . . $ grn_obj# *objectcxx . . $ _grn_highlighter#$anonymous_type_3#object.;
75 grn_encodingcxx . . $ grn_encoding# encodingcxx . . $ _grn_highlighter#$anonymous_type_3#encoding.;
76 grn_objcxx . . $ grn_obj# lazy_keywordscxx . . $ _grn_highlighter#$anonymous_type_3#lazy_keywords.;
77 grn_objcxx . . $ grn_obj# lazy_keyword_idscxx . . $ _grn_highlighter#$anonymous_type_3#lazy_keyword_ids.;
78 grn_objcxx . . $ grn_obj# *token_id_chunkscxx . . $ _grn_highlighter#$anonymous_type_3#token_id_chunks.;
79 grn_objcxx . . $ grn_obj# token_id_chunkcxx . . $ _grn_highlighter#$anonymous_type_3#token_id_chunk.;
80 grn_objcxx . . $ grn_obj# token_idscxx . . $ _grn_highlighter#$anonymous_type_3#token_ids.;
81 grn_objcxx . . $ grn_obj# token_locationscxx . . $ _grn_highlighter#$anonymous_type_3#token_locations.;
82 grn_objcxx . . $ grn_obj# candidatescxx . . $ _grn_highlighter#$anonymous_type_3#candidates.;
83 } lexiconcxx . . $ _grn_highlighter#lexicon.;
84
85 /* For patricia trie mode */
86 structcxx . . $ _grn_highlighter#$anonymous_type_4# {
87 grn_objcxx . . $ grn_obj# *keywordscxx . . $ _grn_highlighter#$anonymous_type_4#keywords.;
88 grn_objcxx . . $ grn_obj# normalizerscxx . . $ _grn_highlighter#$anonymous_type_4#normalizers.;
89 } patcxx . . $ _grn_highlighter#pat.;
90 };
91
92 grn_highlightercxx . . $ grn_highlighter# *
93 grn_highlighter_opencxx . . $ grn_highlighter_open(f7e87339fceabe42).(grn_ctxcxx . . $ grn_ctx# *ctx)
94 {
95 grn_highlightercxx . . $ grn_highlighter# *highlighter;
96
97 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
98
99 highlighter = GRN_CALLOCcxx . . $ `lib/grn_alloc.h:42:9`!(sizeof(grn_highlighter));
100 if (!highlighter) {
101 char errbuf[GRN_CTX_MSGSIZEcxx . . $ `include/groonga/groonga.h:334:9`!];
102 grn_strcpycxx . . $ `include/groonga/portability.h:101:11`!(errbuf, GRN_CTX_MSGSIZE, ctx->errbuf);
103 ERRcxx . . $ `lib/grn_error.h:156:9`!(ctx->rc, "[highlighter][open] failed to allocate memory: %s", errbuf);
104 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
105 }
106
107 highlighter->headercxx . . $ _grn_highlighter#header..typecxx . . $ _grn_obj_header#type. = GRN_HIGHLIGHTERcxx . . $ `include/groonga/groonga.h:884:9`!;
108 highlighter->headercxx . . $ _grn_highlighter#header..impl_flagscxx . . $ _grn_obj_header#impl_flags. = 0;
109 highlighter->headercxx . . $ _grn_highlighter#header..flagscxx . . $ _grn_obj_header#flags. = 0;
110 highlighter->headercxx . . $ _grn_highlighter#header..domaincxx . . $ _grn_obj_header#domain. = GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!;
111
112 highlighter->is_html_modecxx . . $ _grn_highlighter#is_html_mode. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
113 highlighter->need_preparedcxx . . $ _grn_highlighter#need_prepared. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
114 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&(highlighter->raw_keywords), GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!);
115
116 highlighter->is_sequential_class_tag_modecxx . . $ _grn_highlighter#is_sequential_class_tag_mode. = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
117 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&(highlighter->sequential_class_tag.open), 0);
118 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&(highlighter->sequential_class_tag.close), 0);
119
120 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&(highlighter->default_tag.open), 0);
121 grn_highlighter_set_default_open_tagcxx . . $ grn_highlighter_set_default_open_tag(fa1e26c9a0881d65).(ctx,
122 highlighter,
123 GRN_HIGHLIGHTER_DEFAULT_OPEN_TAGcxx . . $ `lib/highlighter.c:26:9`!,
124 -1);
125 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&(highlighter->default_tag.close), 0);
126 grn_highlighter_set_default_close_tagcxx . . $ grn_highlighter_set_default_close_tag(fa1e26c9a0881d65).(ctx,
127 highlighter,
128 GRN_HIGHLIGHTER_DEFAULT_CLOSE_TAGcxx . . $ `lib/highlighter.c:27:9`!,
129 -1);
130
131 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&(highlighter->open_tags), GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!);
132 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&(highlighter->close_tags), GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!);
133 highlighter->n_tagscxx . . $ _grn_highlighter#n_tags. = 0;
134
135 highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..objectcxx . . $ _grn_highlighter#$anonymous_type_3#object. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
136 highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..encodingcxx . . $ _grn_highlighter#$anonymous_type_3#encoding. = GRN_ENC_NONEcxx . . $ GRN_ENC_NONE.;
137 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&(highlighter->lexicon.lazy_keywords), GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!);
138 GRN_RECORD_INITcxx . . $ `include/groonga/groonga.h:2868:9`!(&(highlighter->lexicon.lazy_keyword_ids),
139 GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!,
140 GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!);
141 highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..token_id_chunkscxx . . $ _grn_highlighter#$anonymous_type_3#token_id_chunks. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
142 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&(highlighter->lexicon.token_id_chunk), 0);
143 GRN_RECORD_INITcxx . . $ `include/groonga/groonga.h:2868:9`!(&(highlighter->lexicon.token_ids),
144 GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!,
145 GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!);
146 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&(highlighter->lexicon.token_locations), 0);
147 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&(highlighter->lexicon.candidates), 0);
148
149 highlighter->patcxx . . $ _grn_highlighter#pat..keywordscxx . . $ _grn_highlighter#$anonymous_type_4#keywords. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
150 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&(highlighter->pat.normalizers), 0);
151 grn_highlighter_set_normalizerscxx . . $ grn_highlighter_set_normalizers(fa1e26c9a0881d65).(ctx, highlighter, "NormalizerAuto", -1);
152
153 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(highlighter);
154 }
155
156 grn_rccxx . . $ grn_rc#
157 grn_highlighter_closecxx . . $ grn_highlighter_close(dea94e7f118230eb).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_highlightercxx . . $ grn_highlighter# *highlighter)
158 {
159 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
160
161 if (!highlighter) {
162 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(ctx->rc);
163 }
164
165 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(highlighter->pat.normalizers));
166 if (highlighter->patcxx . . $ _grn_highlighter#pat..keywordscxx . . $ _grn_highlighter#$anonymous_type_4#keywords.) {
167 grn_obj_closecxx . . $ grn_obj_close(4865d068a46d0f83).(ctx, highlighter->patcxx . . $ _grn_highlighter#pat..keywordscxx . . $ _grn_highlighter#$anonymous_type_4#keywords.);
168 }
169
170 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(highlighter->lexicon.lazy_keywords));
171 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(highlighter->lexicon.lazy_keyword_ids));
172 if (highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..token_id_chunkscxx . . $ _grn_highlighter#$anonymous_type_3#token_id_chunks.) {
173 grn_obj_closecxx . . $ grn_obj_close(4865d068a46d0f83).(ctx, highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..token_id_chunkscxx . . $ _grn_highlighter#$anonymous_type_3#token_id_chunks.);
174 }
175 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(highlighter->lexicon.token_id_chunk));
176 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(highlighter->lexicon.candidates));
177 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(highlighter->lexicon.token_locations));
178 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(highlighter->lexicon.token_ids));
179
180 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(highlighter->open_tags));
181 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(highlighter->close_tags));
182
183 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(highlighter->default_tag.open));
184 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(highlighter->default_tag.close));
185
186 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(highlighter->sequential_class_tag.open));
187 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(highlighter->sequential_class_tag.close));
188
189 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &(highlighter->raw_keywords));
190 GRN_FREEcxx . . $ `lib/grn_alloc.h:49:9`!(highlighter);
191
192 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(ctx->rc);
193 }
194
195 static void
196 grn_highlighter_prepare_lexicon_add_token_id_chunkscxx . . $ grn_highlighter_prepare_lexicon_add_token_id_chunks(2e1bdb57b24ba167).(
197 grn_ctxcxx . . $ grn_ctx# *ctx,
198 grn_highlightercxx . . $ grn_highlighter# *highlighter,
199 grn_tokencxx . . $ grn_token# **tokens,
200 size_t n_tokens,
201 grn_objcxx . . $ grn_obj# *token_id_chunk)
202 {
203 if (n_tokens == 0) {
204 if (GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(token_id_chunk) == 0) {
205 return;
206 }
207 grn_encodingcxx . . $ grn_encoding# encoding = ctx->encodingcxx . . $ _grn_ctx#encoding.;
208 /* token_id_chunk is a binary data */
209 ctx->encodingcxx . . $ _grn_ctx#encoding. = GRN_ENC_NONEcxx . . $ GRN_ENC_NONE.;
210 grn_table_addcxx . . $ grn_table_add(8041cb9a4866097e).(ctx,
211 highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..token_id_chunkscxx . . $ _grn_highlighter#$anonymous_type_3#token_id_chunks.,
212 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(token_id_chunk),
213 (unsigned int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(token_id_chunk),
214 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
215 ctx->encodingcxx . . $ _grn_ctx#encoding. = encoding;
216 } else {
217 grn_tokencxx . . $ grn_token# *token = tokens[0];
218 grn_objcxx . . $ grn_obj# *token_data = grn_token_get_datacxx . . $ grn_token_get_data(fa6b3ffdb9b18cb).(ctx, token);
219 /* Expand immature token later. */
220 if (grn_token_get_force_prefix_searchcxx . . $ grn_token_get_force_prefix_search(5548dc6ca4c05dee).(ctx, token) &&
221 highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..objectcxx . . $ _grn_highlighter#$anonymous_type_3#object.->headercxx . . $ _grn_obj#header..typecxx . . $ _grn_obj_header#type. != GRN_TABLE_HASH_KEYcxx . . $ `include/groonga/groonga.h:895:9`!) {
222 grn_objcxx . . $ grn_obj# *lazy_keywords = &(highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..lazy_keywordscxx . . $ _grn_highlighter#$anonymous_type_3#lazy_keywords.);
223 grn_vector_add_elementcxx . . $ grn_vector_add_element(d170aee3d3986928).(ctx,
224 lazy_keywords,
225 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(token_data),
226 (uint32_tcxx . . $ uint32_t#)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(token_data),
227 0,
228 GRN_DB_TEXTcxx . . $ GRN_DB_TEXT.);
229 }
230 grn_token_statuscxx . . $ grn_token_status# token_status = grn_token_get_statuscxx . . $ grn_token_get_status(e181e4c8cedfccbf).(ctx, token);
231 if (token_status & GRN_TOKEN_UNMATUREDcxx . . $ `include/groonga/token.h:94:9`! &&
232 token_status & GRN_TOKEN_OVERLAPcxx . . $ `include/groonga/token.h:88:9`!) {
233 /* This skips the current token.
234 *
235 * GRN_TOKENIZE_GET don't emit immature and overlapped token
236 * such as "c" in ["ab", "bc", "c"] for 'abc' with
237 * TokenNgram. But GRN_TOKENIZE_ONLY doesn't do it. So we do it
238 * manually here. */
239 grn_highlighter_prepare_lexicon_add_token_id_chunkscxx . . $ grn_highlighter_prepare_lexicon_add_token_id_chunks(2e1bdb57b24ba167).(ctx,
240 highlighter,
241 tokens + 1,
242 n_tokens - 1,
243 token_id_chunk);
244 } else {
245 grn_idcxx . . $ grn_id# token_id = GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!;
246 /* We should not use grn_table_get() here. If we use
247 * grn_table_get(), token is normalized twice. */
248 switch (highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..objectcxx . . $ _grn_highlighter#$anonymous_type_3#object.->headercxx . . $ _grn_obj#header..typecxx . . $ _grn_obj_header#type.) {
249 case GRN_TABLE_HASH_KEYcxx . . $ `include/groonga/groonga.h:895:9`!:
250 token_id = grn_hash_getcxx . . $ grn_hash_get(4e868e5367e71b67).(ctx,
251 (grn_hashcxx . . $ grn_hash# *)(highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..objectcxx . . $ _grn_highlighter#$anonymous_type_3#object.),
252 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(token_data),
253 GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(token_data),
254 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
255 break;
256 case GRN_TABLE_PAT_KEYcxx . . $ `include/groonga/groonga.h:896:9`!:
257 token_id = grn_pat_getcxx . . $ grn_pat_get(fa992a8ddbc8af6f).(ctx,
258 (grn_patcxx . . $ grn_pat# *)(highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..objectcxx . . $ _grn_highlighter#$anonymous_type_3#object.),
259 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(token_data),
260 GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(token_data),
261 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
262 break;
263 case GRN_TABLE_DAT_KEYcxx . . $ `include/groonga/groonga.h:897:9`!:
264 token_id = grn_dat_getcxx . . $ grn_dat_get(57fd449a22d316b4).(ctx,
265 (grn_datcxx . . $ grn_dat# *)(highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..objectcxx . . $ _grn_highlighter#$anonymous_type_3#object.),
266 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(token_data),
267 GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(token_data),
268 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
269 break;
270 }
271 /* GRN_TOKENIZE_ONLY may emit a token that doesn't exist in
272 * lexicon. */
273 if (token_id == GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!) {
274 /* Lexicon: ["ab", "bc", "c"]
275 * Input: "abd"
276 * Tokens: ["ab", "bd", "d"]
277 * ^
278 * The current token
279 *
280 * Register the current token ID chunk (["ab"]), ignore "bd"
281 * and start a new token ID chunk ([]) with the next token
282 * ("d").
283 */
284
285 /* Register the current token ID chunk. */
286 grn_highlighter_prepare_lexicon_add_token_id_chunkscxx . . $ grn_highlighter_prepare_lexicon_add_token_id_chunks(2e1bdb57b24ba167).(ctx,
287 highlighter,
288 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
289 0,
290 token_id_chunk);
291 /* Ignore the current token and start a new token ID chunk
292 * from here. */
293 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(token_id_chunk);
294 grn_highlighter_prepare_lexicon_add_token_id_chunkscxx . . $ grn_highlighter_prepare_lexicon_add_token_id_chunks(2e1bdb57b24ba167).(ctx,
295 highlighter,
296 tokens + 1,
297 n_tokens - 1,
298 token_id_chunk);
299 } else {
300 /* This is for loose mode. In loose mode, we have two
301 * tokenized blocks that are separated by
302 * GRN_TOKENIER_END_MARK_UTF8 with GRN_TOKENIZE_ONLY.
303 *
304 * Example:
305 * Tokenizer: TokenNgram("loose_blank", true)
306 * Normalizer: NormalizerNFKC150
307 * Input: "a b"
308 * Tokens: ["a", "b", "U+FFF0", "ab"]
309 * ^
310 * GRN_TOKENIZER_END_MARK_UTF8
311 *
312 * If we found the separator, we split tokens with the
313 * separator and create two token ID chunks. */
314 if (GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(token_data) == GRN_TOKENIZER_END_MARK_UTF8_LENcxx . . $ `include/groonga/tokenizer.h:35:9`! &&
315 memcmpcxx . . $ memcmp(36f949851efa3055).(GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(token_data),
316 GRN_TOKENIZER_END_MARK_UTF8cxx . . $ `include/groonga/tokenizer.h:34:9`!,
317 GRN_TOKENIZER_END_MARK_UTF8_LENcxx . . $ `include/groonga/tokenizer.h:35:9`!) == 0) {
318 /* Register the current token ID chunk. */
319 grn_highlighter_prepare_lexicon_add_token_id_chunkscxx . . $ grn_highlighter_prepare_lexicon_add_token_id_chunks(2e1bdb57b24ba167).(ctx,
320 highlighter,
321 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
322 0,
323 token_id_chunk);
324 if (n_tokens > 1) {
325 /* If we have more tokens after we skip the
326 * GRN_TOKENIZER_END_MARK_UTF8 token, clear the current
327 * token ID chunk and start a new token ID chunk for
328 * tokens followed by the GRN_TOKENIZER_END_MARK_UTF8
329 * token. */
330 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(token_id_chunk);
331 grn_highlighter_prepare_lexicon_add_token_id_chunkscxx . . $ grn_highlighter_prepare_lexicon_add_token_id_chunks(2e1bdb57b24ba167).(ctx,
332 highlighter,
333 tokens + 1,
334 n_tokens - 1,
335 token_id_chunk);
336 }
337 } else {
338 /* This is an existing token. We just add the current token
339 * to the current token ID chunk and continue collecting
340 * more tokens. */
341 GRN_RECORD_PUTcxx . . $ `include/groonga/groonga.h:3213:9`!(ctx, token_id_chunk, token_id);
342 grn_highlighter_prepare_lexicon_add_token_id_chunkscxx . . $ grn_highlighter_prepare_lexicon_add_token_id_chunks(2e1bdb57b24ba167).(ctx,
343 highlighter,
344 tokens + 1,
345 n_tokens - 1,
346 token_id_chunk);
347 grn_idcxx . . $ grn_id# used_token_id;
348 GRN_RECORD_POPcxx . . $ `include/groonga/groonga.h:3247:9`!(token_id_chunk, used_token_id);
349 }
350 }
351 }
352 }
353 }
354
355 static void
356 grn_highlighter_prepare_lexiconcxx . . $ grn_highlighter_prepare_lexicon(dd28725df37ba8d1).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_highlightercxx . . $ grn_highlighter# *highlighter)
357 {
358 grn_objcxx . . $ grn_obj# *lazy_keywords = &(highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..lazy_keywordscxx . . $ _grn_highlighter#$anonymous_type_3#lazy_keywords.);
359 grn_idcxx . . $ grn_id# lexicon_id;
360 size_t i, n_keywords;
361 grn_objcxx . . $ grn_obj# *token_id_chunk = &(highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..token_id_chunkcxx . . $ _grn_highlighter#$anonymous_type_3#token_id_chunk.);
362
363 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(lazy_keywords);
364
365 lexicon_id = grn_obj_idcxx . . $ grn_obj_id(8dd58acc9865e889).(ctx, highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..objectcxx . . $ _grn_highlighter#$anonymous_type_3#object.);
366 highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..lazy_keyword_idscxx . . $ _grn_highlighter#$anonymous_type_3#lazy_keyword_ids..headercxx . . $ _grn_obj#header..domaincxx . . $ _grn_obj_header#domain. = lexicon_id;
367 highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..token_idscxx . . $ _grn_highlighter#$anonymous_type_3#token_ids..headercxx . . $ _grn_obj#header..domaincxx . . $ _grn_obj_header#domain. = lexicon_id;
368
369 grn_table_get_infocxx . . $ grn_table_get_info(a1e4a6d36d3aee7c).(ctx,
370 highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..objectcxx . . $ _grn_highlighter#$anonymous_type_3#object.,
371 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
372 &(highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..encodingcxx . . $ _grn_highlighter#$anonymous_type_3#encoding.),
373 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
374 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
375 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
376
377 if (highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..token_id_chunkscxx . . $ _grn_highlighter#$anonymous_type_3#token_id_chunks.) {
378 grn_table_truncatecxx . . $ grn_table_truncate(4865d068a46d0f83).(ctx, highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..token_id_chunkscxx . . $ _grn_highlighter#$anonymous_type_3#token_id_chunks.);
379 } else {
380 highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..token_id_chunkscxx . . $ _grn_highlighter#$anonymous_type_3#token_id_chunks. =
381 grn_table_createcxx . . $ grn_table_create(51df5019e8d3bdc1).(ctx,
382 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
383 0,
384 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
385 GRN_OBJ_TABLE_PAT_KEYcxx . . $ `include/groonga/groonga.h:689:9`!,
386 grn_ctx_atcxx . . $ grn_ctx_at(ac4544c8400954c9).(ctx, GRN_DB_SHORT_TEXTcxx . . $ GRN_DB_SHORT_TEXT.),
387 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
388 if (!highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..token_id_chunkscxx . . $ _grn_highlighter#$anonymous_type_3#token_id_chunks.) {
389 grn_rccxx . . $ grn_rc# rc = ctx->rccxx . . $ _grn_ctx#rc.;
390 char errbuf[GRN_CTX_MSGSIZEcxx . . $ `include/groonga/groonga.h:334:9`!];
391 if (rc == GRN_SUCCESScxx . . $ GRN_SUCCESS.) {
392 rc = GRN_UNKNOWN_ERRORcxx . . $ GRN_UNKNOWN_ERROR.;
393 }
394 grn_strcpycxx . . $ `include/groonga/portability.h:101:11`!(errbuf, GRN_CTX_MSGSIZE, ctx->errbuf);
395 ERRcxx . . $ `lib/grn_error.h:156:9`!(rc,
396 "[highlighter][prepare][lexicon] "
397 "failed to create an internal patricia trie: %s",
398 errbuf);
399 return;
400 }
401 }
402
403 n_keywords = grn_vector_sizecxx . . $ grn_vector_size(8dd58acc9865e889).(ctx, &(highlighter->raw_keywordscxx . . $ _grn_highlighter#raw_keywords.));
404 for (i = 0; i < n_keywords; i++) {
405 const char *keyword;
406 unsigned int keyword_length;
407 grn_token_cursorcxx . . $ grn_token_cursor# *cursor;
408
409 keyword_length = grn_vector_get_elementcxx . . $ grn_vector_get_element(744613554bd9830c).(ctx,
410 &(highlighter->raw_keywordscxx . . $ _grn_highlighter#raw_keywords.),
411 (uint32_tcxx . . $ uint32_t#)i,
412 &keyword,
413 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
414 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
415
416 grn_objcxx . . $ grn_obj# tokens;
417 /* grn_token isn't grn_obj but we use GRN_PTR here for easy to implement...
418 */
419 GRN_PTR_INITcxx . . $ `include/groonga/groonga.h:2869:9`!(&tokens, GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!, GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!);
420 cursor = grn_token_cursor_opencxx . . $ grn_token_cursor_open(b521006a1987c493).(ctx,
421 highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..objectcxx . . $ _grn_highlighter#$anonymous_type_3#object.,
422 keyword,
423 keyword_length,
424 GRN_TOKENIZE_ONLYcxx . . $ GRN_TOKENIZE_ONLY.,
425 0);
426 if (!cursor) {
427 continue;
428 }
429 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(token_id_chunk);
430 while (cursor->statuscxx . . $ _grn_token_cursor#status. != GRN_TOKEN_CURSOR_DONEcxx . . $ GRN_TOKEN_CURSOR_DONE.) {
431 grn_token_cursor_nextcxx . . $ grn_token_cursor_next(60c29d5cf5463368).(ctx, cursor);
432 grn_tokencxx . . $ grn_token# *token = grn_token_cursor_get_tokencxx . . $ grn_token_cursor_get_token(42eb6886c4ba0dd1).(ctx, cursor);
433 /* This may be needless. */
434 grn_objcxx . . $ grn_obj# *token_data = grn_token_get_datacxx . . $ grn_token_get_data(fa6b3ffdb9b18cb).(ctx, token);
435 if (GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(token_data) == 0) {
436 break;
437 }
438 grn_tokencxx . . $ grn_token# *copied_token = GRN_MALLOCcxx . . $ `lib/grn_alloc.h:41:9`!(sizeof(grn_token));
439 grn_token_init_deepcxx . . $ grn_token_init_deep(c8f3c42adffbb855).(ctx, copied_token);
440 grn_token_copycxx . . $ grn_token_copy(d8752d628fc40805).(ctx, copied_token, token);
441 GRN_PTR_PUTcxx . . $ `include/groonga/groonga.h:3218:9`!(ctx, &tokens, copied_token);
442 }
443 grn_token_cursor_closecxx . . $ grn_token_cursor_close(fbd52f00bdc6c9ff).(ctx, cursor);
444
445 size_t n_tokens = GRN_PTR_VECTOR_SIZEcxx . . $ `include/groonga/groonga.h:3265:9`!(&tokens);
446 if (n_tokens == 0) {
447 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &tokens);
448 continue;
449 }
450 grn_tokencxx . . $ grn_token# **raw_tokens = (grn_tokencxx . . $ grn_token# **)GRN_BULK_HEADcxx . . $ `include/groonga/groonga.h:2648:9`!(&tokens);
451 grn_highlighter_prepare_lexicon_add_token_id_chunkscxx . . $ grn_highlighter_prepare_lexicon_add_token_id_chunks(2e1bdb57b24ba167).(ctx,
452 highlighter,
453 raw_tokens,
454 n_tokens,
455 token_id_chunk);
456 size_t i;
457 for (i = 0; i < n_tokens; i++) {
458 grn_token_fincxx . . $ grn_token_fin(c8f3c42adffbb855).(ctx, raw_tokens[i]);
459 GRN_FREEcxx . . $ `lib/grn_alloc.h:49:9`!(raw_tokens[i]);
460 }
461 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &tokens);
462 }
463 }
464
465 static void
466 grn_highlighter_prepare_patricia_triecxx . . $ grn_highlighter_prepare_patricia_trie(dd28725df37ba8d1).(grn_ctxcxx . . $ grn_ctx# *ctx,
467 grn_highlightercxx . . $ grn_highlighter# *highlighter)
468 {
469 if (highlighter->patcxx . . $ _grn_highlighter#pat..keywordscxx . . $ _grn_highlighter#$anonymous_type_4#keywords.) {
470 grn_table_truncatecxx . . $ grn_table_truncate(4865d068a46d0f83).(ctx, highlighter->patcxx . . $ _grn_highlighter#pat..keywordscxx . . $ _grn_highlighter#$anonymous_type_4#keywords.);
471 } else {
472 highlighter->patcxx . . $ _grn_highlighter#pat..keywordscxx . . $ _grn_highlighter#$anonymous_type_4#keywords. =
473 grn_table_createcxx . . $ grn_table_create(51df5019e8d3bdc1).(ctx,
474 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
475 0,
476 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
477 GRN_OBJ_TABLE_PAT_KEYcxx . . $ `include/groonga/groonga.h:689:9`!,
478 grn_ctx_atcxx . . $ grn_ctx_at(ac4544c8400954c9).(ctx, GRN_DB_SHORT_TEXTcxx . . $ GRN_DB_SHORT_TEXT.),
479 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
480 if (!highlighter->patcxx . . $ _grn_highlighter#pat..keywordscxx . . $ _grn_highlighter#$anonymous_type_4#keywords.) {
481 grn_rccxx . . $ grn_rc# rc = ctx->rccxx . . $ _grn_ctx#rc.;
482 char errbuf[GRN_CTX_MSGSIZEcxx . . $ `include/groonga/groonga.h:334:9`!];
483 if (rc == GRN_SUCCESScxx . . $ GRN_SUCCESS.) {
484 rc = GRN_UNKNOWN_ERRORcxx . . $ GRN_UNKNOWN_ERROR.;
485 }
486 grn_strcpycxx . . $ `include/groonga/portability.h:101:11`!(errbuf, GRN_CTX_MSGSIZE, ctx->errbuf);
487 ERRcxx . . $ `lib/grn_error.h:156:9`!(rc,
488 "[highlighter][prepare][no-lexicon] "
489 "failed to create an internal patricia trie: %s",
490 errbuf);
491 return;
492 }
493 }
494
495 if (highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..objectcxx . . $ _grn_highlighter#$anonymous_type_3#object.) {
496 grn_objcxx . . $ grn_obj# normalizers;
497 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&normalizers, 0);
498 grn_table_get_normalizers_stringcxx . . $ grn_table_get_normalizers_string(d825b4ed5bf12304).(ctx,
499 highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..objectcxx . . $ _grn_highlighter#$anonymous_type_3#object.,
500 &normalizers);
501 grn_obj_set_infocxx . . $ grn_obj_set_info(1c4fe9650683f16e).(ctx,
502 highlighter->patcxx . . $ _grn_highlighter#pat..keywordscxx . . $ _grn_highlighter#$anonymous_type_4#keywords.,
503 GRN_INFO_NORMALIZERScxx . . $ GRN_INFO_NORMALIZERS.,
504 &normalizers);
505 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &normalizers);
506 } else {
507 grn_obj_set_infocxx . . $ grn_obj_set_info(1c4fe9650683f16e).(ctx,
508 highlighter->patcxx . . $ _grn_highlighter#pat..keywordscxx . . $ _grn_highlighter#$anonymous_type_4#keywords.,
509 GRN_INFO_NORMALIZERScxx . . $ GRN_INFO_NORMALIZERS.,
510 &(highlighter->patcxx . . $ _grn_highlighter#pat..normalizerscxx . . $ _grn_highlighter#$anonymous_type_4#normalizers.));
511 }
512 if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESScxx . . $ GRN_SUCCESS.) {
513 return;
514 }
515
516 {
517 unsigned int i, n;
518
519 n = grn_vector_sizecxx . . $ grn_vector_size(8dd58acc9865e889).(ctx, &(highlighter->raw_keywordscxx . . $ _grn_highlighter#raw_keywords.));
520 for (i = 0; i < n; i++) {
521 const char *keyword;
522 unsigned int keyword_size;
523
524 keyword_size = grn_vector_get_elementcxx . . $ grn_vector_get_element(744613554bd9830c).(ctx,
525 &(highlighter->raw_keywordscxx . . $ _grn_highlighter#raw_keywords.),
526 i,
527 &keyword,
528 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
529 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
530 grn_table_addcxx . . $ grn_table_add(8041cb9a4866097e).(ctx,
531 highlighter->patcxx . . $ _grn_highlighter#pat..keywordscxx . . $ _grn_highlighter#$anonymous_type_4#keywords.,
532 keyword,
533 keyword_size,
534 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
535 }
536 }
537 }
538
539 static void
540 grn_highlighter_preparecxx . . $ grn_highlighter_prepare(dd28725df37ba8d1).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_highlightercxx . . $ grn_highlighter# *highlighter)
541 {
542 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! use_lexicon = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
543 if (highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..objectcxx . . $ _grn_highlighter#$anonymous_type_3#object.) {
544 grn_objcxx . . $ grn_obj# *tokenizer;
545 grn_table_get_infocxx . . $ grn_table_get_info(a1e4a6d36d3aee7c).(ctx,
546 highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..objectcxx . . $ _grn_highlighter#$anonymous_type_3#object.,
547 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
548 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
549 &tokenizer,
550 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
551 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
552 use_lexicon = (tokenizer != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
553 }
554 if (use_lexicon) {
555 grn_highlighter_prepare_lexiconcxx . . $ grn_highlighter_prepare_lexicon(dd28725df37ba8d1).(ctx, highlighter);
556 if (highlighter->patcxx . . $ _grn_highlighter#pat..keywordscxx . . $ _grn_highlighter#$anonymous_type_4#keywords.) {
557 grn_obj_closecxx . . $ grn_obj_close(4865d068a46d0f83).(ctx, highlighter->patcxx . . $ _grn_highlighter#pat..keywordscxx . . $ _grn_highlighter#$anonymous_type_4#keywords.);
558 highlighter->patcxx . . $ _grn_highlighter#pat..keywordscxx . . $ _grn_highlighter#$anonymous_type_4#keywords. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
559 }
560 } else {
561 grn_highlighter_prepare_patricia_triecxx . . $ grn_highlighter_prepare_patricia_trie(dd28725df37ba8d1).(ctx, highlighter);
562 }
563 size_t n_open_tags = grn_vector_sizecxx . . $ grn_vector_size(8dd58acc9865e889).(ctx, &(highlighter->open_tagscxx . . $ _grn_highlighter#open_tags.));
564 size_t n_close_tags = grn_vector_sizecxx . . $ grn_vector_size(8dd58acc9865e889).(ctx, &(highlighter->close_tagscxx . . $ _grn_highlighter#close_tags.));
565 highlighter->n_tagscxx . . $ _grn_highlighter#n_tags. = (n_open_tags == n_close_tags ? n_open_tags : 0);
566 highlighter->need_preparedcxx . . $ _grn_highlighter#need_prepared. = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
567 }
568
569 static boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`!
570 grn_ids_is_includedcxx . . $ grn_ids_is_included(ba5c2805edfda4d8).(grn_idcxx . . $ grn_id# *ids, size_t n_ids, grn_idcxx . . $ grn_id# id)
571 {
572 size_t i;
573
574 for (i = 0; i < n_ids; i++) {
575 if (ids[i] == id) {
576 return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
577 }
578 }
579
580 return falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
581 }
582
583 static void
584 grn_highlighter_log_locationcxx . . $ grn_highlighter_log_location(232a858f447fc04f).(grn_ctxcxx . . $ grn_ctx# *ctx,
585 grn_log_levelcxx . . $ grn_log_level# level,
586 const char *tag,
587 grn_highlighter_locationcxx . . $ grn_highlighter_location# *location,
588 const char *text,
589 size_t text_length)
590 {
591 if (!grn_logger_passcxx . . $ grn_logger_pass(188766080ec9c0f2).(ctx, level)) {
592 return;
593 }
594
595 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx,
596 level,
597 "%s[location] "
598 "[%" GRN_FMT_INT64Ucxx . . $ `lib/grn.h:370:11`! "...%" GRN_FMT_INT64Ucxx . . $ `lib/grn.h:370:11`! "](%u)[%s] <%.*s>",
599 tag,
600 location->offset,
601 location->offset + location->length,
602 location->first_character_length,
603 location->have_overlap ? "overlapped" : "not-overlapped",
604 (int)location->length,
605 text + location->offset);
606 }
607
608 static void
609 grn_highlighter_highlight_get_ith_tagcxx . . $ grn_highlighter_highlight_get_ith_tag(c6583acffa4df2e5).(grn_ctxcxx . . $ grn_ctx# *ctx,
610 grn_highlightercxx . . $ grn_highlighter# *highlighter,
611 size_t i,
612 const char **open_tag,
613 size_t *open_tag_length,
614 const char **close_tag,
615 size_t *close_tag_length)
616 {
617 if (highlighter->is_sequential_class_tag_modecxx . . $ _grn_highlighter#is_sequential_class_tag_mode.) {
618 size_t n_keywords = grn_vector_sizecxx . . $ grn_vector_size(8dd58acc9865e889).(ctx, &(highlighter->raw_keywordscxx . . $ _grn_highlighter#raw_keywords.));
619 i = i % n_keywords;
620 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&(highlighter->sequential_class_tag.open));
621 grn_text_printfcxx . . $ grn_text_printf(34596149d4dc0292).(ctx,
622 &(highlighter->sequential_class_tagcxx . . $ _grn_highlighter#sequential_class_tag..opencxx . . $ _grn_highlighter#$anonymous_type_1#open.),
623 "<mark class=\"keyword-%" GRN_FMT_SIZEcxx . . $ `lib/grn.h:408:11`! "\">",
624 i);
625 GRN_TEXT_SETScxx . . $ `include/groonga/groonga.h:2783:9`!(ctx, &(highlighter->sequential_class_tag.close), "</mark>");
626 *open_tag = GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&(highlighter->sequential_class_tag.open));
627 *open_tag_length = GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&(highlighter->sequential_class_tag.open));
628 *close_tag = GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&(highlighter->sequential_class_tag.close));
629 *close_tag_length =
630 GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&(highlighter->sequential_class_tag.close));
631 } else if (highlighter->n_tagscxx . . $ _grn_highlighter#n_tags. == 0) {
632 *open_tag = GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&(highlighter->default_tag.open));
633 *open_tag_length = GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&(highlighter->default_tag.open)) - 1;
634 *close_tag = GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&(highlighter->default_tag.close));
635 *close_tag_length = GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&(highlighter->default_tag.close)) - 1;
636 } else {
637 i = i % highlighter->n_tagscxx . . $ _grn_highlighter#n_tags.;
638 *open_tag_length = grn_vector_get_elementcxx . . $ grn_vector_get_element(744613554bd9830c).(ctx,
639 &(highlighter->open_tagscxx . . $ _grn_highlighter#open_tags.),
640 i,
641 open_tag,
642 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
643 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
644 *close_tag_length = grn_vector_get_elementcxx . . $ grn_vector_get_element(744613554bd9830c).(ctx,
645 &(highlighter->close_tagscxx . . $ _grn_highlighter#close_tags.),
646 i,
647 close_tag,
648 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
649 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
650 }
651 }
652
653 static void
654 grn_highlighter_highlight_add_normal_textcxx . . $ grn_highlighter_highlight_add_normal_text(af6adf433d0fa4a1).(grn_ctxcxx . . $ grn_ctx# *ctx,
655 grn_highlightercxx . . $ grn_highlighter# *highlighter,
656 grn_objcxx . . $ grn_obj# *output,
657 const char *text,
658 size_t text_length)
659 {
660 if (highlighter->is_html_modecxx . . $ _grn_highlighter#is_html_mode.) {
661 grn_text_escape_xmlcxx . . $ grn_text_escape_xml(4609c18fd87cf054).(ctx, output, text, text_length);
662 } else {
663 GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, output, text, text_length);
664 }
665 }
666
667 static uint64_tcxx . . $ uint64_t#
668 grn_highlighter_highlight_lexicon_flushcxx . . $ grn_highlighter_highlight_lexicon_flush(ffd32f546ecb296f).(grn_ctxcxx . . $ grn_ctx# *ctx,
669 grn_log_levelcxx . . $ grn_log_level# log_level,
670 const char *tag,
671 grn_highlightercxx . . $ grn_highlighter# *highlighter,
672 const char *text,
673 size_t text_length,
674 grn_objcxx . . $ grn_obj# *output,
675 grn_highlighter_locationcxx . . $ grn_highlighter_location# *location,
676 uint64_tcxx . . $ uint64_t# offset)
677 {
678 grn_highlighter_log_locationcxx . . $ grn_highlighter_log_location(232a858f447fc04f).(ctx,
679 log_level,
680 tag,
681 location,
682 text,
683 text_length);
684 if (location->offsetcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#offset. > offset) {
685 grn_highlighter_highlight_add_normal_textcxx . . $ grn_highlighter_highlight_add_normal_text(af6adf433d0fa4a1).(
686 ctx,
687 highlighter,
688 output,
689 text + offset,
690 (size_t)(location->offsetcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#offset. - offset));
691 }
692
693 const char *open_tag;
694 size_t open_tag_length;
695 const char *close_tag;
696 size_t close_tag_length;
697 grn_highlighter_highlight_get_ith_tagcxx . . $ grn_highlighter_highlight_get_ith_tag(c6583acffa4df2e5).(ctx,
698 highlighter,
699 /* We need "- 1" here
700 * because grn_id doesn't
701 * use 0 (GRN_ID_NIL). */
702 location->chunk_idcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#chunk_id. - 1,
703 &open_tag,
704 &open_tag_length,
705 &close_tag,
706 &close_tag_length);
707 GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, output, open_tag, open_tag_length);
708 grn_highlighter_highlight_add_normal_textcxx . . $ grn_highlighter_highlight_add_normal_text(af6adf433d0fa4a1).(ctx,
709 highlighter,
710 output,
711 text + location->offsetcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#offset.,
712 location->lengthcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#length.);
713 GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, output, close_tag, close_tag_length);
714 return location->offsetcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#offset. + location->lengthcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#length.;
715 }
716
717 static void
718 grn_highlighter_tokenize_lexiconcxx . . $ grn_highlighter_tokenize_lexicon(f7686baafa6e09e2).(grn_ctxcxx . . $ grn_ctx# *ctx,
719 grn_highlightercxx . . $ grn_highlighter# *highlighter,
720 const char *text,
721 size_t text_length)
722 {
723 const char *tag = "[highlighter][highlight][lexicon]";
724 grn_log_levelcxx . . $ grn_log_level# log_level = GRN_LOG_DEBUGcxx . . $ GRN_LOG_DEBUG.;
725 grn_objcxx . . $ grn_obj# *token_ids = &(highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..token_idscxx . . $ _grn_highlighter#$anonymous_type_3#token_ids.);
726 grn_objcxx . . $ grn_obj# *token_locations = &(highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..token_locationscxx . . $ _grn_highlighter#$anonymous_type_3#token_locations.);
727
728 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(token_ids);
729 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(token_locations);
730 grn_token_cursorcxx . . $ grn_token_cursor# *cursor = grn_token_cursor_opencxx . . $ grn_token_cursor_open(b521006a1987c493).(ctx,
731 highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..objectcxx . . $ _grn_highlighter#$anonymous_type_3#object.,
732 text,
733 text_length,
734 GRN_TOKENIZE_ADDcxx . . $ GRN_TOKENIZE_ADD.,
735 0);
736 if (!cursor) {
737 char errbuf[GRN_CTX_MSGSIZEcxx . . $ `include/groonga/groonga.h:334:9`!];
738 grn_strcpycxx . . $ `include/groonga/portability.h:101:11`!(errbuf, GRN_CTX_MSGSIZE, ctx->errbuf);
739 ERRcxx . . $ `lib/grn_error.h:156:9`!(ctx->rc, "%s failed to start tokenizing: %s", tag, errbuf);
740 return;
741 }
742
743 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, log_level, "%s[tokenize][start]", tag);
744 while (cursor->statuscxx . . $ _grn_token_cursor#status. == GRN_TOKEN_CURSOR_DOINGcxx . . $ GRN_TOKEN_CURSOR_DOING.) {
745 grn_idcxx . . $ grn_id# token_id = grn_token_cursor_nextcxx . . $ grn_token_cursor_next(60c29d5cf5463368).(ctx, cursor);
746 grn_highlighter_locationcxx . . $ grn_highlighter_location# location;
747 grn_tokencxx . . $ grn_token# *token;
748
749 if (token_id == GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!) {
750 continue;
751 }
752 token = grn_token_cursor_get_tokencxx . . $ grn_token_cursor_get_token(42eb6886c4ba0dd1).(ctx, cursor);
753 GRN_RECORD_PUTcxx . . $ `include/groonga/groonga.h:3213:9`!(ctx, token_ids, token_id);
754 location.offsetcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#offset. = grn_token_get_source_offsetcxx . . $ grn_token_get_source_offset(6b88337da967ca79).(ctx, token);
755 location.lengthcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#length. = grn_token_get_source_lengthcxx . . $ grn_token_get_source_length(e181e4c8cedfccbf).(ctx, token);
756 location.first_character_lengthcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#first_character_length. =
757 grn_token_get_source_first_character_lengthcxx . . $ grn_token_get_source_first_character_length(e181e4c8cedfccbf).(ctx, token);
758 location.have_overlapcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#have_overlap. = grn_token_have_overlapcxx . . $ grn_token_have_overlap(5548dc6ca4c05dee).(ctx, token);
759 GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, token_locations, &location, sizeof(location));
760 grn_highlighter_log_locationcxx . . $ grn_highlighter_log_location(232a858f447fc04f).(ctx,
761 log_level,
762 tag,
763 &location,
764 text,
765 text_length);
766 }
767 grn_token_cursor_closecxx . . $ grn_token_cursor_close(fbd52f00bdc6c9ff).(ctx, cursor);
768 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, log_level, "%s[tokenize][end]", tag);
769 }
770
771 static void
772 grn_highlighter_highlight_lexiconcxx . . $ grn_highlighter_highlight_lexicon(347c235500bdd121).(grn_ctxcxx . . $ grn_ctx# *ctx,
773 grn_highlightercxx . . $ grn_highlighter# *highlighter,
774 const char *text,
775 size_t text_length,
776 grn_objcxx . . $ grn_obj# *output)
777 {
778 const char *tag = "[highlighter][highlight][lexicon]";
779 grn_log_levelcxx . . $ grn_log_level# log_level = GRN_LOG_DEBUGcxx . . $ GRN_LOG_DEBUG.;
780 grn_objcxx . . $ grn_obj# *lazy_keyword_ids = &(highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..lazy_keyword_idscxx . . $ _grn_highlighter#$anonymous_type_3#lazy_keyword_ids.);
781 grn_objcxx . . $ grn_obj# *token_ids = &(highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..token_idscxx . . $ _grn_highlighter#$anonymous_type_3#token_ids.);
782 grn_objcxx . . $ grn_obj# *token_locations = &(highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..token_locationscxx . . $ _grn_highlighter#$anonymous_type_3#token_locations.);
783 grn_objcxx . . $ grn_obj# *candidates = &(highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..candidatescxx . . $ _grn_highlighter#$anonymous_type_3#candidates.);
784
785 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(lazy_keyword_ids);
786
787 {
788 grn_objcxx . . $ grn_obj# *lexicon = highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..objectcxx . . $ _grn_highlighter#$anonymous_type_3#object.;
789 grn_objcxx . . $ grn_obj# *chunks = highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..token_id_chunkscxx . . $ _grn_highlighter#$anonymous_type_3#token_id_chunks.;
790 grn_objcxx . . $ grn_obj# *lazy_keywords = &(highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..lazy_keywordscxx . . $ _grn_highlighter#$anonymous_type_3#lazy_keywords.);
791 size_t i;
792 size_t n_keywords;
793
794 n_keywords = grn_vector_sizecxx . . $ grn_vector_size(8dd58acc9865e889).(ctx, lazy_keywords);
795 for (i = 0; i < n_keywords; i++) {
796 const char *keyword;
797 unsigned int keyword_length;
798
799 keyword_length = grn_vector_get_elementcxx . . $ grn_vector_get_element(744613554bd9830c).(ctx,
800 lazy_keywords,
801 (uint32_tcxx . . $ uint32_t#)i,
802 &keyword,
803 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
804 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
805 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx,
806 log_level,
807 "%s[prefix-search][start] %" GRN_FMT_SIZEcxx . . $ `lib/grn.h:408:11`! ":<%.*s>",
808 tag,
809 i,
810 (int)keyword_length,
811 keyword);
812 GRN_TABLE_EACH_BEGIN_MINcxx . . $ `include/groonga/table.h:648:9`!(ctx,
813 lexicon,
814 cursor,
815 id,
816 keyword,
817 keyword_length,
818 GRN_CURSOR_PREFIXcxx . . $ `include/groonga/table.h:281:9`!)
819 {
820 int added = 0;
821
822 {
823 grn_encodingcxx . . $ grn_encoding# encoding = ctx->encodingcxx . . $ _grn_ctx#encoding.;
824 ctx->encodingcxx . . $ _grn_ctx#encoding. = GRN_ENC_NONEcxx . . $ GRN_ENC_NONE.;
825 grn_table_addcxx . . $ grn_table_add(8041cb9a4866097e).(ctx, chunks, &id, sizeof(grn_idcxx . . $ grn_id#), &added);
826 ctx->encodingcxx . . $ _grn_ctx#encoding. = encoding;
827 }
828 if (grn_logger_passcxx . . $ grn_logger_pass(188766080ec9c0f2).(ctx, log_level)) {
829 void *key;
830 int key_size;
831 key_size = grn_table_cursor_get_keycxx . . $ grn_table_cursor_get_key(7d620ebe94cee13a).(ctx, cursor, &key);
832 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx,
833 log_level,
834 "%s[prefix-search][%s] %" GRN_FMT_SIZEcxx . . $ `lib/grn.h:408:11`! ":<%.*s>:<%.*s>",
835 tag,
836 added ? "added" : "not-added",
837 i,
838 (int)keyword_length,
839 keyword,
840 key_size,
841 (const char *)key);
842 }
843 if (added) {
844 GRN_RECORD_PUTcxx . . $ `include/groonga/groonga.h:3213:9`!(ctx, lazy_keyword_ids, id);
845 }
846 }
847 GRN_TABLE_EACH_ENDcxx . . $ `include/groonga/table.h:665:9`!(ctx, cursor);
848 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx,
849 log_level,
850 "%s[prefix-search][end] %" GRN_FMT_SIZEcxx . . $ `lib/grn.h:408:11`! ":<%.*s>",
851 tag,
852 i,
853 (int)keyword_length,
854 keyword);
855 }
856 }
857
858 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(candidates);
859 {
860 grn_objcxx . . $ grn_obj# *lazy_keyword_ids = &(highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..lazy_keyword_idscxx . . $ _grn_highlighter#$anonymous_type_3#lazy_keyword_ids.);
861 grn_idcxx . . $ grn_id# *raw_lazy_keyword_ids;
862 size_t n_lazy_keyword_ids;
863 grn_patcxx . . $ grn_pat# *chunks = (grn_patcxx . . $ grn_pat# *)(highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..token_id_chunkscxx . . $ _grn_highlighter#$anonymous_type_3#token_id_chunks.);
864 size_t i;
865 size_t n_token_ids = GRN_BULK_VSIZEcxx . . $ `include/groonga/groonga.h:2642:9`!(token_ids) / sizeof(grn_idcxx . . $ grn_id#);
866 grn_idcxx . . $ grn_id# *raw_token_ids = (grn_idcxx . . $ grn_id# *)GRN_BULK_HEADcxx . . $ `include/groonga/groonga.h:2648:9`!(token_ids);
867 grn_highlighter_locationcxx . . $ grn_highlighter_location# *raw_token_locations =
868 (grn_highlighter_locationcxx . . $ grn_highlighter_location# *)GRN_BULK_HEADcxx . . $ `include/groonga/groonga.h:2648:9`!(token_locations);
869
870 raw_lazy_keyword_ids = (grn_idcxx . . $ grn_id# *)GRN_BULK_HEADcxx . . $ `include/groonga/groonga.h:2648:9`!(lazy_keyword_ids);
871 n_lazy_keyword_ids = GRN_BULK_VSIZEcxx . . $ `include/groonga/groonga.h:2642:9`!(lazy_keyword_ids) / sizeof(grn_idcxx . . $ grn_id#);
872
873 for (i = 0; i < n_token_ids; i++) {
874 grn_idcxx . . $ grn_id# chunk_id;
875
876 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, log_level, "%s[lcp-search][start] %" GRN_FMT_SIZEcxx . . $ `lib/grn.h:408:11`!, tag, i);
877 {
878 grn_encodingcxx . . $ grn_encoding# encoding = ctx->encodingcxx . . $ _grn_ctx#encoding.;
879 /* token_id_chunk is a binary data */
880 ctx->encodingcxx . . $ _grn_ctx#encoding. = GRN_ENC_NONEcxx . . $ GRN_ENC_NONE.;
881 chunk_id =
882 grn_pat_lcp_searchcxx . . $ grn_pat_lcp_search(16c60b50be975ec9).(ctx,
883 chunks,
884 raw_token_ids + i,
885 (unsigned int)(n_token_ids - i) * sizeof(grn_idcxx . . $ grn_id#));
886 ctx->encodingcxx . . $ _grn_ctx#encoding. = encoding;
887 }
888 if (chunk_id == GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!) {
889 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx,
890 log_level,
891 "%s[lcp-search][end][nonexistent] %" GRN_FMT_SIZEcxx . . $ `lib/grn.h:408:11`!,
892 tag,
893 i);
894 continue;
895 }
896
897 {
898 grn_idcxx . . $ grn_id# *ids;
899 uint32_tcxx . . $ uint32_t# key_size;
900 size_t n_ids;
901 grn_highlighter_locationcxx . . $ grn_highlighter_location# candidate;
902 grn_highlighter_locationcxx . . $ grn_highlighter_location# *first = raw_token_locations + i;
903
904 candidate.chunk_idcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#chunk_id. = chunk_id;
905 candidate.have_overlapcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#have_overlap. = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
906 candidate.first_character_lengthcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#first_character_length. = 0;
907
908 {
909 grn_encodingcxx . . $ grn_encoding# encoding = ctx->encodingcxx . . $ _grn_ctx#encoding.;
910 ctx->encodingcxx . . $ _grn_ctx#encoding. = GRN_ENC_NONEcxx . . $ GRN_ENC_NONE.;
911 ids = (grn_idcxx . . $ grn_id# *)_grn_pat_keycxx . . $ _grn_pat_key(5b74e3d4f3bf1aa4).(ctx, chunks, chunk_id, &key_size);
912 ctx->encodingcxx . . $ _grn_ctx#encoding. = encoding;
913 }
914 n_ids = key_size / sizeof(grn_idcxx . . $ grn_id#);
915 candidate.offsetcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#offset. = first->offsetcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#offset.;
916 if (n_ids == 1) {
917 if (grn_ids_is_includedcxx . . $ grn_ids_is_included(ba5c2805edfda4d8).(raw_lazy_keyword_ids,
918 n_lazy_keyword_ids,
919 ids[0])) {
920 candidate.lengthcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#length. = first->first_character_lengthcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#first_character_length.;
921 } else {
922 candidate.lengthcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#length. = first->lengthcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#length.;
923 }
924 } else {
925 grn_highlighter_locationcxx . . $ grn_highlighter_location# *last = raw_token_locations + i + n_ids - 1;
926 candidate.lengthcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#length. = last->offsetcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#offset. + last->lengthcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#length. - candidate.offsetcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#offset.;
927 }
928 GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, candidates, &candidate, sizeof(candidate));
929 grn_highlighter_log_locationcxx . . $ grn_highlighter_log_location(232a858f447fc04f).(ctx,
930 log_level,
931 tag,
932 &candidate,
933 text,
934 text_length);
935 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, log_level, "%s[lcp-search][end] %" GRN_FMT_SIZEcxx . . $ `lib/grn.h:408:11`!, tag, i);
936 i += n_ids - 1;
937 }
938 }
939 }
940
941 {
942 grn_objcxx . . $ grn_obj# *chunks = highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..token_id_chunkscxx . . $ _grn_highlighter#$anonymous_type_3#token_id_chunks.;
943 size_t i, n_ids;
944
945 n_ids = GRN_BULK_VSIZEcxx . . $ `include/groonga/groonga.h:2642:9`!(lazy_keyword_ids) / sizeof(grn_idcxx . . $ grn_id#);
946 for (i = 0; i < n_ids; i++) {
947 grn_idcxx . . $ grn_id# id = GRN_RECORD_VALUE_ATcxx . . $ `include/groonga/groonga.h:3148:9`!(lazy_keyword_ids, i);
948 grn_encodingcxx . . $ grn_encoding# encoding = ctx->encodingcxx . . $ _grn_ctx#encoding.;
949 ctx->encodingcxx . . $ _grn_ctx#encoding. = GRN_ENC_NONEcxx . . $ GRN_ENC_NONE.;
950 grn_table_deletecxx . . $ grn_table_delete(e105391b8a53b2cf).(ctx, chunks, &id, sizeof(grn_idcxx . . $ grn_id#));
951 ctx->encodingcxx . . $ _grn_ctx#encoding. = encoding;
952 }
953 }
954
955 {
956 size_t i;
957 size_t n_candidates =
958 GRN_BULK_VSIZEcxx . . $ `include/groonga/groonga.h:2642:9`!(candidates) / sizeof(grn_highlighter_locationcxx . . $ grn_highlighter_location#);
959 grn_highlighter_locationcxx . . $ grn_highlighter_location# *raw_candidates =
960 (grn_highlighter_locationcxx . . $ grn_highlighter_location# *)GRN_BULK_HEADcxx . . $ `include/groonga/groonga.h:2648:9`!(candidates);
961
962 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx,
963 log_level,
964 "%s[highlight][start] %" GRN_FMT_SIZEcxx . . $ `lib/grn.h:408:11`!,
965 tag,
966 n_candidates);
967 if (n_candidates == 0) {
968 grn_text_escape_xmlcxx . . $ grn_text_escape_xml(4609c18fd87cf054).(ctx, output, text, text_length);
969 } else {
970 grn_highlighter_locationcxx . . $ grn_highlighter_location# *previous = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
971 uint64_tcxx . . $ uint64_t# offset = 0;
972
973 qsortcxx . . $ qsort(ebb60b13a65e77d7).(raw_candidates,
974 n_candidates,
975 sizeof(grn_highlighter_locationcxx . . $ grn_highlighter_location#),
976 grn_highlighter_location_comparecxx . . $ grn_highlighter_location_compare(9148c8c3ff42c9d8).);
977 previous = raw_candidates;
978 for (i = 1; i < n_candidates; i++) {
979 grn_highlighter_locationcxx . . $ grn_highlighter_location# *current = raw_candidates + i;
980 if (previous->offsetcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#offset. + previous->lengthcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#length. >= current->offsetcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#offset.) {
981 if (previous->offsetcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#offset. + previous->lengthcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#length. >
982 current->offsetcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#offset. + current->lengthcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#length.) {
983 current->lengthcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#length. = previous->lengthcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#length.;
984 } else {
985 current->lengthcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#length. += (uint32_tcxx . . $ uint32_t#)(current->offsetcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#offset. - previous->offsetcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#offset.);
986 }
987 current->offsetcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#offset. = previous->offsetcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#offset.;
988 previous = current;
989 continue;
990 }
991 if (current->offsetcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#offset. > previous->offsetcxx . . $ $anonymous_type_1fe099f70d3b3fd3_0#offset.) {
992 offset = grn_highlighter_highlight_lexicon_flushcxx . . $ grn_highlighter_highlight_lexicon_flush(ffd32f546ecb296f).(ctx,
993 log_level,
994 tag,
995 highlighter,
996 text,
997 text_length,
998 output,
999 previous,
1000 offset);
1001 }
1002 previous = current;
1003 }
1004 offset = grn_highlighter_highlight_lexicon_flushcxx . . $ grn_highlighter_highlight_lexicon_flush(ffd32f546ecb296f).(ctx,
1005 log_level,
1006 tag,
1007 highlighter,
1008 text,
1009 text_length,
1010 output,
1011 previous,
1012 offset);
1013 if (offset < text_length) {
1014 grn_highlighter_highlight_add_normal_textcxx . . $ grn_highlighter_highlight_add_normal_text(af6adf433d0fa4a1).(
1015 ctx,
1016 highlighter,
1017 output,
1018 text + offset,
1019 (size_t)(text_length - offset));
1020 }
1021 }
1022 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx,
1023 log_level,
1024 "%s[highlight][end] %" GRN_FMT_SIZEcxx . . $ `lib/grn.h:408:11`!,
1025 tag,
1026 n_candidates);
1027 }
1028 }
1029
1030 static void
1031 grn_highlighter_highlight_patricia_triecxx . . $ grn_highlighter_highlight_patricia_trie(347c235500bdd121).(grn_ctxcxx . . $ grn_ctx# *ctx,
1032 grn_highlightercxx . . $ grn_highlighter# *highlighter,
1033 const char *text,
1034 size_t text_length,
1035 grn_objcxx . . $ grn_obj# *output)
1036 {
1037 const char *current = text;
1038 size_t current_length = text_length;
1039
1040 while (current_length > 0) {
1041 #define MAX_N_HITScxx . . $ `lib/highlighter.c:1041:9`! 16
1042 grn_pat_scan_hitcxx . . $ grn_pat_scan_hit# hits[MAX_N_HITScxx . . $ `lib/highlighter.c:1041:9`!];
1043 const char *rest;
1044 int i, n_hits;
1045 size_t previous_length = 0;
1046 size_t chunk_length;
1047
1048 n_hits = grn_pat_scancxx . . $ grn_pat_scan(656402c9c3a16ac).(ctx,
1049 (grn_patcxx . . $ grn_pat# *)(highlighter->patcxx . . $ _grn_highlighter#pat..keywordscxx . . $ _grn_highlighter#$anonymous_type_4#keywords.),
1050 current,
1051 (unsigned int)current_length,
1052 hits,
1053 MAX_N_HITScxx . . $ `lib/highlighter.c:1041:9`!,
1054 &rest);
1055 for (i = 0; i < n_hits; i++) {
1056 const char *open_tag;
1057 size_t open_tag_length;
1058 const char *close_tag;
1059 size_t close_tag_length;
1060 grn_highlighter_highlight_get_ith_tagcxx . . $ grn_highlighter_highlight_get_ith_tag(c6583acffa4df2e5).(ctx,
1061 highlighter,
1062 /* We need "- 1" here
1063 * because grn_id doesn't
1064 * use 0 (GRN_ID_NIL). */
1065 hits[i].idcxx . . $ _grn_table_scan_hit#id. - 1,
1066 &open_tag,
1067 &open_tag_length,
1068 &close_tag,
1069 &close_tag_length);
1070
1071 if ((hits[i].offsetcxx . . $ _grn_table_scan_hit#offset. - previous_length) > 0) {
1072 grn_highlighter_highlight_add_normal_textcxx . . $ grn_highlighter_highlight_add_normal_text(af6adf433d0fa4a1).(ctx,
1073 highlighter,
1074 output,
1075 current + previous_length,
1076 hits[i].offsetcxx . . $ _grn_table_scan_hit#offset. -
1077 previous_length);
1078 }
1079 GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, output, open_tag, open_tag_length);
1080 grn_highlighter_highlight_add_normal_textcxx . . $ grn_highlighter_highlight_add_normal_text(af6adf433d0fa4a1).(ctx,
1081 highlighter,
1082 output,
1083 current + hits[i].offsetcxx . . $ _grn_table_scan_hit#offset.,
1084 hits[i].lengthcxx . . $ _grn_table_scan_hit#length.);
1085 GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, output, close_tag, close_tag_length);
1086 previous_length = hits[i].offsetcxx . . $ _grn_table_scan_hit#offset. + hits[i].lengthcxx . . $ _grn_table_scan_hit#length.;
1087 }
1088
1089 chunk_length = (size_t)(rest - current);
1090 if ((chunk_length - previous_length) > 0) {
1091 grn_highlighter_highlight_add_normal_textcxx . . $ grn_highlighter_highlight_add_normal_text(af6adf433d0fa4a1).(ctx,
1092 highlighter,
1093 output,
1094 current + previous_length,
1095 current_length -
1096 previous_length);
1097 }
1098 current_length -= chunk_length;
1099 current = rest;
1100 #undef MAX_N_HITScxx . . $ `lib/highlighter.c:1041:9`!
1101 }
1102 }
1103
1104 grn_rccxx . . $ grn_rc#
1105 grn_highlighter_highlightcxx . . $ grn_highlighter_highlight(632d74b7a20d517f).(grn_ctxcxx . . $ grn_ctx# *ctx,
1106 grn_highlightercxx . . $ grn_highlighter# *highlighter,
1107 const char *text,
1108 int64_tcxx . . $ int64_t# text_length,
1109 grn_objcxx . . $ grn_obj# *output)
1110 {
1111 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
1112
1113 if (text_length < 0) {
1114 text_length = (int64_tcxx . . $ int64_t#)strlencxx . . $ strlen(751346f8406fd082).(text);
1115 }
1116
1117 if (text_length == 0) {
1118 goto exit;
1119 }
1120
1121 if (grn_vector_sizecxx . . $ grn_vector_size(8dd58acc9865e889).(ctx, &(highlighter->raw_keywordscxx . . $ _grn_highlighter#raw_keywords.)) == 0) {
1122 grn_highlighter_highlight_add_normal_textcxx . . $ grn_highlighter_highlight_add_normal_text(af6adf433d0fa4a1).(ctx,
1123 highlighter,
1124 output,
1125 text,
1126 (size_t)text_length);
1127 goto exit;
1128 }
1129
1130 if (highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..objectcxx . . $ _grn_highlighter#$anonymous_type_3#object.) {
1131 /* We need to tokenize the target text with GRN_TOKENIZE_ADD
1132 * before we call grn_highlighter_prepare_lexicon() because
1133 * grn_highlighter_prepare_lexicon() assumes that the tokens of
1134 * the target text exists in highlighter->lexicon.object.
1135 *
1136 * If we have any new tokens, we need to re-prepare. */
1137 uint32_tcxx . . $ uint32_t# size_before = grn_table_sizecxx . . $ grn_table_size(8dd58acc9865e889).(ctx, highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..objectcxx . . $ _grn_highlighter#$anonymous_type_3#object.);
1138 grn_highlighter_tokenize_lexiconcxx . . $ grn_highlighter_tokenize_lexicon(f7686baafa6e09e2).(ctx, highlighter, text, text_length);
1139 if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESScxx . . $ GRN_SUCCESS.) {
1140 goto exit;
1141 }
1142 uint32_tcxx . . $ uint32_t# size_after = grn_table_sizecxx . . $ grn_table_size(8dd58acc9865e889).(ctx, highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..objectcxx . . $ _grn_highlighter#$anonymous_type_3#object.);
1143 if (size_after > size_before) {
1144 highlighter->need_preparedcxx . . $ _grn_highlighter#need_prepared. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
1145 }
1146 }
1147
1148 if (highlighter->need_preparedcxx . . $ _grn_highlighter#need_prepared.) {
1149 grn_highlighter_preparecxx . . $ grn_highlighter_prepare(dd28725df37ba8d1).(ctx, highlighter);
1150 if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESScxx . . $ GRN_SUCCESS.) {
1151 goto exit;
1152 }
1153 }
1154
1155 if (highlighter->patcxx . . $ _grn_highlighter#pat..keywordscxx . . $ _grn_highlighter#$anonymous_type_4#keywords.) {
1156 grn_highlighter_highlight_patricia_triecxx . . $ grn_highlighter_highlight_patricia_trie(347c235500bdd121).(ctx,
1157 highlighter,
1158 text,
1159 (size_t)text_length,
1160 output);
1161 } else {
1162 grn_highlighter_highlight_lexiconcxx . . $ grn_highlighter_highlight_lexicon(347c235500bdd121).(ctx,
1163 highlighter,
1164 text,
1165 (size_t)text_length,
1166 output);
1167 }
1168
1169 exit:
1170 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(ctx->rc);
1171 }
1172
1173 grn_rccxx . . $ grn_rc#
1174 grn_highlighter_set_lexiconcxx . . $ grn_highlighter_set_lexicon(7d1464b8c57e5d0b).(grn_ctxcxx . . $ grn_ctx# *ctx,
1175 grn_highlightercxx . . $ grn_highlighter# *highlighter,
1176 grn_objcxx . . $ grn_obj# *lexicon)
1177 {
1178 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
1179
1180 if (highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..objectcxx . . $ _grn_highlighter#$anonymous_type_3#object. != lexicon) {
1181 highlighter->need_preparedcxx . . $ _grn_highlighter#need_prepared. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
1182 highlighter->lexiconcxx . . $ _grn_highlighter#lexicon..objectcxx . . $ _grn_highlighter#$anonymous_type_3#object. = lexicon;
1183 }
1184
1185 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(ctx->rc);
1186 }
1187
1188 grn_objcxx . . $ grn_obj# *
1189 grn_highlighter_get_lexiconcxx . . $ grn_highlighter_get_lexicon(3ca3ced0f6b5f51a).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_highlightercxx . . $ grn_highlighter# *highlighter)
1190 {
1191 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
1192
1193 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(highlighter->lexicon.object);
1194 }
1195
1196 grn_rccxx . . $ grn_rc#
1197 grn_highlighter_set_default_open_tagcxx . . $ grn_highlighter_set_default_open_tag(fa1e26c9a0881d65).(grn_ctxcxx . . $ grn_ctx# *ctx,
1198 grn_highlightercxx . . $ grn_highlighter# *highlighter,
1199 const char *tag,
1200 int64_tcxx . . $ int64_t# tag_length)
1201 {
1202 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
1203 if (tag_length < 0) {
1204 tag_length = strlencxx . . $ strlen(751346f8406fd082).(tag);
1205 }
1206 GRN_TEXT_SETcxx . . $ `include/groonga/groonga.h:2761:9`!(ctx, &(highlighter->default_tag.open), tag, tag_length);
1207 GRN_TEXT_PUTCcxx . . $ `include/groonga/groonga.h:2775:9`!(ctx, &(highlighter->default_tag.open), '\0');
1208 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(ctx->rc);
1209 }
1210
1211 const char *
1212 grn_highlighter_get_default_open_tagcxx . . $ grn_highlighter_get_default_open_tag(da86dd17a793e7e7).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_highlightercxx . . $ grn_highlighter# *highlighter)
1213 {
1214 return GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&(highlighter->default_tag.open));
1215 }
1216
1217 grn_rccxx . . $ grn_rc#
1218 grn_highlighter_set_default_close_tagcxx . . $ grn_highlighter_set_default_close_tag(fa1e26c9a0881d65).(grn_ctxcxx . . $ grn_ctx# *ctx,
1219 grn_highlightercxx . . $ grn_highlighter# *highlighter,
1220 const char *tag,
1221 int64_tcxx . . $ int64_t# tag_length)
1222 {
1223 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
1224 if (tag_length < 0) {
1225 tag_length = strlencxx . . $ strlen(751346f8406fd082).(tag);
1226 }
1227 GRN_TEXT_SETcxx . . $ `include/groonga/groonga.h:2761:9`!(ctx, &(highlighter->default_tag.close), tag, tag_length);
1228 GRN_TEXT_PUTCcxx . . $ `include/groonga/groonga.h:2775:9`!(ctx, &(highlighter->default_tag.close), '\0');
1229 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(ctx->rc);
1230 }
1231
1232 const char *
1233 grn_highlighter_get_default_close_tagcxx . . $ grn_highlighter_get_default_close_tag(da86dd17a793e7e7).(grn_ctxcxx . . $ grn_ctx# *ctx,
1234 grn_highlightercxx . . $ grn_highlighter# *highlighter)
1235 {
1236 return GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&(highlighter->default_tag.close));
1237 }
1238
1239 grn_rccxx . . $ grn_rc#
1240 grn_highlighter_set_sequential_class_tag_modecxx . . $ grn_highlighter_set_sequential_class_tag_mode(e400292976c965f5).(grn_ctxcxx . . $ grn_ctx# *ctx,
1241 grn_highlightercxx . . $ grn_highlighter# *highlighter,
1242 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! mode)
1243 {
1244 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
1245 highlighter->is_sequential_class_tag_modecxx . . $ _grn_highlighter#is_sequential_class_tag_mode. = mode;
1246 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(ctx->rc);
1247 }
1248
1249 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`!
1250 grn_highlighter_get_sequential_class_tag_modecxx . . $ grn_highlighter_get_sequential_class_tag_mode(ee9c6a653e6dc363).(grn_ctxcxx . . $ grn_ctx# *ctx,
1251 grn_highlightercxx . . $ grn_highlighter# *highlighter)
1252 {
1253 return highlighter->is_sequential_class_tag_modecxx . . $ _grn_highlighter#is_sequential_class_tag_mode.;
1254 }
1255
1256 grn_rccxx . . $ grn_rc#
1257 grn_highlighter_set_normalizerscxx . . $ grn_highlighter_set_normalizers(fa1e26c9a0881d65).(grn_ctxcxx . . $ grn_ctx# *ctx,
1258 grn_highlightercxx . . $ grn_highlighter# *highlighter,
1259 const char *normalizers,
1260 int64_tcxx . . $ int64_t# normalizers_length)
1261 {
1262 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
1263 if (normalizers_length < 0) {
1264 normalizers_length = strlencxx . . $ strlen(751346f8406fd082).(normalizers);
1265 }
1266 GRN_TEXT_SETcxx . . $ `include/groonga/groonga.h:2761:9`!(ctx,
1267 &(highlighter->pat.normalizers),
1268 normalizers,
1269 normalizers_length);
1270 highlighter->need_preparedcxx . . $ _grn_highlighter#need_prepared. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
1271 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(ctx->rc);
1272 }
1273
1274 grn_objcxx . . $ grn_obj# *
1275 grn_highlighter_get_normalizerscxx . . $ grn_highlighter_get_normalizers(3ca3ced0f6b5f51a).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_highlightercxx . . $ grn_highlighter# *highlighter)
1276 {
1277 return &(highlighter->patcxx . . $ _grn_highlighter#pat..normalizerscxx . . $ _grn_highlighter#$anonymous_type_4#normalizers.);
1278 }
1279
1280 grn_rccxx . . $ grn_rc#
1281 grn_highlighter_set_html_modecxx . . $ grn_highlighter_set_html_mode(e400292976c965f5).(grn_ctxcxx . . $ grn_ctx# *ctx,
1282 grn_highlightercxx . . $ grn_highlighter# *highlighter,
1283 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! html_mode)
1284 {
1285 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
1286 highlighter->is_html_modecxx . . $ _grn_highlighter#is_html_mode. = html_mode;
1287 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(ctx->rc);
1288 }
1289
1290 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`!
1291 grn_highlighter_get_html_modecxx . . $ grn_highlighter_get_html_mode(ee9c6a653e6dc363).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_highlightercxx . . $ grn_highlighter# *highlighter)
1292 {
1293 return highlighter->is_html_modecxx . . $ _grn_highlighter#is_html_mode.;
1294 }
1295
1296 grn_rccxx . . $ grn_rc#
1297 grn_highlighter_add_keywordcxx . . $ grn_highlighter_add_keyword(fa1e26c9a0881d65).(grn_ctxcxx . . $ grn_ctx# *ctx,
1298 grn_highlightercxx . . $ grn_highlighter# *highlighter,
1299 const char *keyword,
1300 int64_tcxx . . $ int64_t# keyword_length)
1301 {
1302 unsigned int i, n_keywords;
1303 grn_objcxx . . $ grn_obj# *raw_keywords = &(highlighter->raw_keywordscxx . . $ _grn_highlighter#raw_keywords.);
1304
1305 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
1306
1307 if (keyword_length < 0) {
1308 keyword_length = (int64_tcxx . . $ int64_t#)strlencxx . . $ strlen(751346f8406fd082).(keyword);
1309 }
1310
1311 if (keyword_length == 0) {
1312 goto exit;
1313 }
1314
1315 n_keywords = grn_vector_sizecxx . . $ grn_vector_size(8dd58acc9865e889).(ctx, raw_keywords);
1316 for (i = 0; i < n_keywords; i++) {
1317 const char *existing_keyword;
1318 unsigned int length;
1319
1320 length = grn_vector_get_elementcxx . . $ grn_vector_get_element(744613554bd9830c).(ctx,
1321 raw_keywords,
1322 i,
1323 &existing_keyword,
1324 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
1325 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
1326 if (length == keyword_length &&
1327 memcmpcxx . . $ memcmp(36f949851efa3055).(keyword, existing_keyword, length) == 0) {
1328 goto exit;
1329 }
1330 }
1331
1332 grn_vector_add_elementcxx . . $ grn_vector_add_element(d170aee3d3986928).(ctx,
1333 raw_keywords,
1334 keyword,
1335 (uint32_tcxx . . $ uint32_t#)keyword_length,
1336 0,
1337 GRN_DB_TEXTcxx . . $ GRN_DB_TEXT.);
1338 highlighter->need_preparedcxx . . $ _grn_highlighter#need_prepared. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
1339
1340 exit:
1341 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(ctx->rc);
1342 }
1343
1344 grn_rccxx . . $ grn_rc#
1345 grn_highlighter_clear_keywordscxx . . $ grn_highlighter_clear_keywords(dea94e7f118230eb).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_highlightercxx . . $ grn_highlighter# *highlighter)
1346 {
1347 grn_objcxx . . $ grn_obj# *raw_keywords = &(highlighter->raw_keywordscxx . . $ _grn_highlighter#raw_keywords.);
1348
1349 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
1350
1351 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(raw_keywords);
1352 highlighter->need_preparedcxx . . $ _grn_highlighter#need_prepared. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
1353
1354 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(ctx->rc);
1355 }
1356
1357 grn_rccxx . . $ grn_rc#
1358 grn_highlighter_add_open_tagcxx . . $ grn_highlighter_add_open_tag(fa1e26c9a0881d65).(grn_ctxcxx . . $ grn_ctx# *ctx,
1359 grn_highlightercxx . . $ grn_highlighter# *highlighter,
1360 const char *tag,
1361 int64_tcxx . . $ int64_t# tag_length)
1362 {
1363 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
1364 if (tag_length < 0) {
1365 tag_length = strlencxx . . $ strlen(751346f8406fd082).(tag);
1366 }
1367 grn_vector_add_elementcxx . . $ grn_vector_add_element(d170aee3d3986928).(ctx,
1368 &(highlighter->open_tagscxx . . $ _grn_highlighter#open_tags.),
1369 tag,
1370 tag_length,
1371 0,
1372 GRN_DB_TEXTcxx . . $ GRN_DB_TEXT.);
1373 highlighter->need_preparedcxx . . $ _grn_highlighter#need_prepared. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
1374 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(ctx->rc);
1375 }
1376
1377 grn_rccxx . . $ grn_rc#
1378 grn_highlighter_add_close_tagcxx . . $ grn_highlighter_add_close_tag(fa1e26c9a0881d65).(grn_ctxcxx . . $ grn_ctx# *ctx,
1379 grn_highlightercxx . . $ grn_highlighter# *highlighter,
1380 const char *tag,
1381 int64_tcxx . . $ int64_t# tag_length)
1382 {
1383 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
1384 if (tag_length < 0) {
1385 tag_length = strlencxx . . $ strlen(751346f8406fd082).(tag);
1386 }
1387 grn_vector_add_elementcxx . . $ grn_vector_add_element(d170aee3d3986928).(ctx,
1388 &(highlighter->close_tagscxx . . $ _grn_highlighter#close_tags.),
1389 tag,
1390 tag_length,
1391 0,
1392 GRN_DB_TEXTcxx . . $ GRN_DB_TEXT.);
1393 highlighter->need_preparedcxx . . $ _grn_highlighter#need_prepared. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
1394 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(ctx->rc);
1395 }
1396
1397 grn_rccxx . . $ grn_rc#
1398 grn_highlighter_clear_tagscxx . . $ grn_highlighter_clear_tags(dea94e7f118230eb).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_highlightercxx . . $ grn_highlighter# *highlighter)
1399 {
1400 GRN_API_ENTERcxx . . $ `lib/grn_ctx.h:41:9`!;
1401 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&(highlighter->open_tags));
1402 GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&(highlighter->close_tags));
1403 highlighter->need_preparedcxx . . $ _grn_highlighter#need_prepared. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
1404 GRN_API_RETURNcxx . . $ `lib/grn_ctx.h:56:9`!(ctx->rc);
1405 }