Debian Codegraph @

lib/proc/proc_highlight.c

raw symbols SCIP
1 /*
2 Copyright (C) 2009-2018 Brazil
3 Copyright (C) 2020-2023 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_proc.h"cxx . . $ `<file>/lib/grn_proc.h`/
21 #include "../grn_expr.h"cxx . . $ `<file>/lib/grn_expr.h`/
22
23 #include <groonga/plugin.h>cxx . . $ `<file>/include/groonga/plugin.h`/
24 #include <string.h>
25
26 static boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`!
27 highlight_validate_text_argcxx . . $ highlight_validate_text_arg(552c086c14054f03).(grn_ctxcxx . . $ grn_ctx# *ctx,
28 grn_objcxx . . $ grn_obj# *arg,
29 const char *function_name,
30 const char *label)
31 {
32 if (grn_obj_is_text_family_bulkcxx . . $ grn_obj_is_text_family_bulk(a5760e5c319a06ee).(ctx, arg)) {
33 return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
34 }
35
36 grn_objcxx . . $ grn_obj# inspected;
37 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&inspected, 0);
38 grn_inspectcxx . . $ grn_inspect(88456f97fe0d41a).(ctx, &inspected, arg);
39 GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx,
40 GRN_INVALID_ARGUMENT,
41 "%s(): %s must be text: %.*s",
42 function_name,
43 label,
44 (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&inspected),
45 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&inspected));
46 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &inspected);
47
48 return falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
49 }
50
51 static grn_objcxx . . $ grn_obj# *
52 func_highlightcxx . . $ func_highlight(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx,
53 int nargs,
54 grn_objcxx . . $ grn_obj# **args,
55 grn_user_datacxx . . $ grn_user_data# *user_data)
56 {
57 const char *tag = "[highlight]";
58 const char *function_name = "highlight";
59 grn_objcxx . . $ grn_obj# *highlighted = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!;
60
61 #define N_REQUIRED_ARGScxx . . $ `lib/proc/proc_highlight.c:61:9`! 1
62 if (nargs > N_REQUIRED_ARGScxx . . $ `lib/proc/proc_highlight.c:61:9`!) {
63 grn_objcxx . . $ grn_obj# *string = args[0];
64 grn_objcxx . . $ grn_obj# *end_arg = args[nargs - 1];
65 int n_args_without_option = nargs;
66
67 grn_objcxx . . $ grn_obj# cache_key;
68 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&cache_key, 0);
69 grn_proc_func_generate_cache_keycxx . . $ grn_proc_func_generate_cache_key(1f5c90cc9be2f095).(ctx,
70 function_name,
71 args + 1,
72 nargs - 1,
73 &cache_key);
74
75 grn_objcxx . . $ grn_obj# *expression;
76 grn_proc_get_infocxx . . $ grn_proc_get_info(760bc9a52c80d02a).(ctx, user_data, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, &expression);
77
78 grn_highlightercxx . . $ grn_highlighter# *highlighter = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!;
79 grn_objcxx . . $ grn_obj# *highlighter_ptr = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!;
80 if (GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&cache_key) <= GRN_TABLE_MAX_KEY_SIZEcxx . . $ `include/groonga/table.h:26:9`!) {
81 highlighter_ptr =
82 grn_expr_get_varcxx . . $ grn_expr_get_var(c00e49795c44129a).(ctx,
83 expression,
84 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&cache_key),
85 (unsigned int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&cache_key));
86 if (highlighter_ptr) {
87 highlighter = (grn_highlightercxx . . $ grn_highlighter# *)GRN_PTR_VALUEcxx . . $ `include/groonga/groonga.h:3111:9`!(highlighter_ptr);
88 } else {
89 highlighter_ptr =
90 grn_expr_get_or_add_varcxx . . $ grn_expr_get_or_add_var(c00e49795c44129a).(ctx,
91 expression,
92 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&cache_key),
93 (unsigned int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&cache_key));
94 if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESScxx . . $ GRN_SUCCESS.) {
95 goto exit;
96 }
97 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, highlighter_ptr);
98 GRN_PTR_INITcxx . . $ `include/groonga/groonga.h:2869:9`!(highlighter_ptr, GRN_OBJ_OWNcxx . . $ `include/groonga/groonga.h:945:9`!, GRN_DB_OBJECT);
99 }
100 }
101 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &cache_key);
102
103 if (!highlighter) {
104 highlighter = grn_highlighter_opencxx . . $ grn_highlighter_open(f7e87339fceabe42).(ctx);
105 if (highlighter_ptr) {
106 GRN_PTR_SETcxx . . $ `include/groonga/groonga.h:2945:9`!(ctx, highlighter_ptr, highlighter);
107 }
108
109 grn_highlighter_set_html_modecxx . . $ grn_highlighter_set_html_mode(e400292976c965f5).(ctx, highlighter, falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!);
110
111 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! need_tag_in_variable_args = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
112
113 if (grn_obj_is_tiny_hash_tablecxx . . $ grn_obj_is_tiny_hash_table(a5760e5c319a06ee).(ctx, end_arg)) {
114 n_args_without_option--;
115
116 grn_raw_stringcxx . . $ grn_raw_string# normalizers;
117 GRN_RAW_STRING_SET_CSTRINGcxx . . $ `include/groonga/raw_string.h:41:9`!(normalizers, "NormalizerAuto");
118 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! html_mode = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
119 grn_raw_stringcxx . . $ grn_raw_string# default_open_tag = {NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, 0};
120 grn_raw_stringcxx . . $ grn_raw_string# default_close_tag = {NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, 0};
121 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! sequential_class_tag_mode = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
122 grn_proc_options_parsecxx . . $ grn_proc_options_parse(b3b87877968531ef).(ctx,
123 end_arg,
124 tag,
125 "normalizer",
126 GRN_PROC_OPTION_VALUE_RAW_STRINGcxx . . $ GRN_PROC_OPTION_VALUE_RAW_STRING.,
127 &normalizers,
128 "normalizers",
129 GRN_PROC_OPTION_VALUE_RAW_STRINGcxx . . $ GRN_PROC_OPTION_VALUE_RAW_STRING.,
130 &normalizers,
131 "html_escape",
132 GRN_PROC_OPTION_VALUE_BOOLcxx . . $ GRN_PROC_OPTION_VALUE_BOOL.,
133 &html_mode,
134 "html_mode",
135 GRN_PROC_OPTION_VALUE_BOOLcxx . . $ GRN_PROC_OPTION_VALUE_BOOL.,
136 &html_mode,
137 "default_open_tag",
138 GRN_PROC_OPTION_VALUE_RAW_STRINGcxx . . $ GRN_PROC_OPTION_VALUE_RAW_STRING.,
139 &default_open_tag,
140 "default_close_tag",
141 GRN_PROC_OPTION_VALUE_RAW_STRINGcxx . . $ GRN_PROC_OPTION_VALUE_RAW_STRING.,
142 &default_close_tag,
143 "sequential_class_tag_mode",
144 GRN_PROC_OPTION_VALUE_BOOLcxx . . $ GRN_PROC_OPTION_VALUE_BOOL.,
145 &sequential_class_tag_mode,
146 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!);
147 if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESScxx . . $ GRN_SUCCESS.) {
148 goto exit;
149 }
150
151 grn_highlighter_set_normalizerscxx . . $ grn_highlighter_set_normalizers(fa1e26c9a0881d65).(ctx,
152 highlighter,
153 normalizers.valuecxx . . $ $anonymous_type_7f733dd816802915_0#value.,
154 normalizers.lengthcxx . . $ $anonymous_type_7f733dd816802915_0#length.);
155 grn_highlighter_set_html_modecxx . . $ grn_highlighter_set_html_mode(e400292976c965f5).(ctx, highlighter, html_mode);
156
157 if (default_open_tag.lengthcxx . . $ $anonymous_type_7f733dd816802915_0#length. > 0) {
158 need_tag_in_variable_args = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
159 grn_highlighter_set_default_open_tagcxx . . $ grn_highlighter_set_default_open_tag(fa1e26c9a0881d65).(ctx,
160 highlighter,
161 default_open_tag.valuecxx . . $ $anonymous_type_7f733dd816802915_0#value.,
162 default_open_tag.lengthcxx . . $ $anonymous_type_7f733dd816802915_0#length.);
163 }
164
165 if (default_close_tag.lengthcxx . . $ $anonymous_type_7f733dd816802915_0#length. > 0) {
166 need_tag_in_variable_args = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
167 grn_highlighter_set_default_close_tagcxx . . $ grn_highlighter_set_default_close_tag(fa1e26c9a0881d65).(ctx,
168 highlighter,
169 default_close_tag.valuecxx . . $ $anonymous_type_7f733dd816802915_0#value.,
170 default_close_tag.lengthcxx . . $ $anonymous_type_7f733dd816802915_0#length.);
171 }
172
173 if (sequential_class_tag_mode) {
174 need_tag_in_variable_args = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
175 }
176 grn_highlighter_set_sequential_class_tag_modecxx . . $ grn_highlighter_set_sequential_class_tag_mode(e400292976c965f5).(
177 ctx,
178 highlighter,
179 sequential_class_tag_mode);
180 }
181
182 grn_objcxx . . $ grn_obj# **keyword_args = args + N_REQUIRED_ARGScxx . . $ `lib/proc/proc_highlight.c:61:9`!;
183 uint32_tcxx . . $ uint32_t# n_keyword_args =
184 (uint32_tcxx . . $ uint32_t#)(n_args_without_option - N_REQUIRED_ARGScxx . . $ `lib/proc/proc_highlight.c:61:9`!);
185 if (need_tag_in_variable_args) {
186 uint32_tcxx . . $ uint32_t# i;
187 for (i = 0; i < n_keyword_args; i += 3) {
188 grn_objcxx . . $ grn_obj# *keyword = keyword_args[i];
189 grn_objcxx . . $ grn_obj# *open_tag = keyword_args[i + 1];
190 grn_objcxx . . $ grn_obj# *close_tag = keyword_args[i + 2];
191 if (!highlight_validate_text_argcxx . . $ highlight_validate_text_arg(552c086c14054f03).(ctx,
192 keyword,
193 function_name,
194 "keyword")) {
195 goto exit;
196 }
197 if (!highlight_validate_text_argcxx . . $ highlight_validate_text_arg(552c086c14054f03).(ctx,
198 open_tag,
199 function_name,
200 "open tag")) {
201 goto exit;
202 }
203 if (!highlight_validate_text_argcxx . . $ highlight_validate_text_arg(552c086c14054f03).(ctx,
204 close_tag,
205 function_name,
206 "close tag")) {
207 goto exit;
208 }
209 grn_highlighter_add_open_tagcxx . . $ grn_highlighter_add_open_tag(fa1e26c9a0881d65).(ctx,
210 highlighter,
211 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(open_tag),
212 GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(open_tag));
213 grn_highlighter_add_close_tagcxx . . $ grn_highlighter_add_close_tag(fa1e26c9a0881d65).(ctx,
214 highlighter,
215 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(close_tag),
216 GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(close_tag));
217 grn_highlighter_add_keywordcxx . . $ grn_highlighter_add_keyword(fa1e26c9a0881d65).(ctx,
218 highlighter,
219 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(keyword),
220 GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(keyword));
221 }
222 } else {
223 uint32_tcxx . . $ uint32_t# i;
224 for (i = 0; i < n_keyword_args; i++) {
225 grn_objcxx . . $ grn_obj# *keyword = keyword_args[i];
226 if (!highlight_validate_text_argcxx . . $ highlight_validate_text_arg(552c086c14054f03).(ctx,
227 keyword,
228 function_name,
229 "keyword")) {
230 goto exit;
231 }
232 grn_highlighter_add_keywordcxx . . $ grn_highlighter_add_keyword(fa1e26c9a0881d65).(ctx,
233 highlighter,
234 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(keyword),
235 GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(keyword));
236 }
237 }
238 }
239
240 highlighted = grn_plugin_proc_alloccxx . . $ grn_plugin_proc_alloc(acb267eca6702fc).(ctx, user_data, GRN_DB_TEXTcxx . . $ GRN_DB_TEXT., 0);
241 grn_highlighter_highlightcxx . . $ grn_highlighter_highlight(632d74b7a20d517f).(ctx,
242 highlighter,
243 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(string),
244 (int64_tcxx . . $ int64_t#)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(string),
245 highlighted);
246 }
247 #undef N_REQUIRED_ARGScxx . . $ `lib/proc/proc_highlight.c:61:9`!
248
249 exit:
250 if (!highlighted) {
251 highlighted = grn_plugin_proc_alloccxx . . $ grn_plugin_proc_alloc(acb267eca6702fc).(ctx, user_data, GRN_DB_VOIDcxx . . $ GRN_DB_VOID., 0);
252 }
253
254 return highlighted;
255 }
256
257 void
258 grn_proc_init_highlightcxx . . $ grn_proc_init_highlight(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx)
259 {
260 grn_proc_createcxx . . $ grn_proc_create(195df001e5324f57).(ctx,
261 "highlight",
262 -1,
263 GRN_PROC_FUNCTIONcxx . . $ GRN_PROC_FUNCTION.,
264 func_highlightcxx . . $ func_highlight(fd082858389c8bb0).,
265 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!,
266 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!,
267 0,
268 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!);
269 }
270
271 static grn_objcxx . . $ grn_obj# *
272 func_highlight_fullcxx . . $ func_highlight_full(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx,
273 int nargs,
274 grn_objcxx . . $ grn_obj# **args,
275 grn_user_datacxx . . $ grn_user_data# *user_data)
276 {
277 const char *function_name = "highlight_full";
278 grn_objcxx . . $ grn_obj# *highlighted = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!;
279
280 #define N_REQUIRED_ARGScxx . . $ `lib/proc/proc_highlight.c:280:9`! 3
281 #define KEYWORD_SET_SIZEcxx . . $ `lib/proc/proc_highlight.c:281:9`! 3
282 if ((nargs >= (N_REQUIRED_ARGScxx . . $ `lib/proc/proc_highlight.c:280:9`! + KEYWORD_SET_SIZEcxx . . $ `lib/proc/proc_highlight.c:281:9`!) &&
283 (nargs - N_REQUIRED_ARGScxx . . $ `lib/proc/proc_highlight.c:280:9`!) % KEYWORD_SET_SIZEcxx . . $ `lib/proc/proc_highlight.c:281:9`! == 0)) {
284 grn_objcxx . . $ grn_obj# *string = args[0];
285
286 grn_objcxx . . $ grn_obj# cache_key;
287 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&cache_key, 0);
288 grn_proc_func_generate_cache_keycxx . . $ grn_proc_func_generate_cache_key(1f5c90cc9be2f095).(ctx,
289 function_name,
290 args + 1,
291 nargs - 1,
292 &cache_key);
293
294 grn_objcxx . . $ grn_obj# *expression;
295 grn_proc_get_infocxx . . $ grn_proc_get_info(760bc9a52c80d02a).(ctx, user_data, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, &expression);
296
297 grn_highlightercxx . . $ grn_highlighter# *highlighter = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!;
298 grn_objcxx . . $ grn_obj# *highlighter_ptr = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!;
299 if (GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&cache_key) <= GRN_TABLE_MAX_KEY_SIZEcxx . . $ `include/groonga/table.h:26:9`!) {
300 highlighter_ptr =
301 grn_expr_get_varcxx . . $ grn_expr_get_var(c00e49795c44129a).(ctx,
302 expression,
303 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&cache_key),
304 (unsigned int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&cache_key));
305 if (highlighter_ptr) {
306 highlighter = (grn_highlightercxx . . $ grn_highlighter# *)GRN_PTR_VALUEcxx . . $ `include/groonga/groonga.h:3111:9`!(highlighter_ptr);
307 } else {
308 highlighter_ptr =
309 grn_expr_get_or_add_varcxx . . $ grn_expr_get_or_add_var(c00e49795c44129a).(ctx,
310 expression,
311 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&cache_key),
312 (unsigned int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&cache_key));
313 if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESScxx . . $ GRN_SUCCESS.) {
314 goto exit;
315 }
316 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, highlighter_ptr);
317 GRN_PTR_INITcxx . . $ `include/groonga/groonga.h:2869:9`!(highlighter_ptr, GRN_OBJ_OWNcxx . . $ `include/groonga/groonga.h:945:9`!, GRN_DB_OBJECT);
318 }
319 }
320 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &cache_key);
321
322 if (!highlighter) {
323 grn_objcxx . . $ grn_obj# *normalizers = args[1];
324 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! html_mode = GRN_BOOL_VALUEcxx . . $ `include/groonga/groonga.h:3097:9`!(args[2]);
325
326 highlighter = grn_highlighter_opencxx . . $ grn_highlighter_open(f7e87339fceabe42).(ctx);
327 if (highlighter_ptr) {
328 GRN_PTR_SETcxx . . $ `include/groonga/groonga.h:2945:9`!(ctx, highlighter_ptr, highlighter);
329 }
330
331 grn_highlighter_set_normalizerscxx . . $ grn_highlighter_set_normalizers(fa1e26c9a0881d65).(ctx,
332 highlighter,
333 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(normalizers),
334 GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(normalizers));
335 grn_highlighter_set_html_modecxx . . $ grn_highlighter_set_html_mode(e400292976c965f5).(ctx, highlighter, html_mode);
336
337 grn_objcxx . . $ grn_obj# **keyword_set_args = args + N_REQUIRED_ARGScxx . . $ `lib/proc/proc_highlight.c:280:9`!;
338 int n_keyword_args = nargs - N_REQUIRED_ARGScxx . . $ `lib/proc/proc_highlight.c:280:9`!;
339 int n_keyword_sets = n_keyword_args / KEYWORD_SET_SIZEcxx . . $ `lib/proc/proc_highlight.c:281:9`!;
340
341 int i;
342 for (i = 0; i < n_keyword_sets; i++) {
343 grn_objcxx . . $ grn_obj# *keyword = keyword_set_args[i * KEYWORD_SET_SIZEcxx . . $ `lib/proc/proc_highlight.c:281:9`! + 0];
344 grn_objcxx . . $ grn_obj# *open_tag = keyword_set_args[i * KEYWORD_SET_SIZEcxx . . $ `lib/proc/proc_highlight.c:281:9`! + 1];
345 grn_objcxx . . $ grn_obj# *close_tag = keyword_set_args[i * KEYWORD_SET_SIZEcxx . . $ `lib/proc/proc_highlight.c:281:9`! + 2];
346
347 if (!highlight_validate_text_argcxx . . $ highlight_validate_text_arg(552c086c14054f03).(ctx,
348 keyword,
349 function_name,
350 "keyword")) {
351 goto exit;
352 }
353 if (!highlight_validate_text_argcxx . . $ highlight_validate_text_arg(552c086c14054f03).(ctx,
354 open_tag,
355 function_name,
356 "open tag")) {
357 goto exit;
358 }
359 if (!highlight_validate_text_argcxx . . $ highlight_validate_text_arg(552c086c14054f03).(ctx,
360 close_tag,
361 function_name,
362 "close tag")) {
363 goto exit;
364 }
365
366 grn_highlighter_add_keywordcxx . . $ grn_highlighter_add_keyword(fa1e26c9a0881d65).(ctx,
367 highlighter,
368 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(keyword),
369 GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(keyword));
370 grn_highlighter_add_open_tagcxx . . $ grn_highlighter_add_open_tag(fa1e26c9a0881d65).(ctx,
371 highlighter,
372 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(open_tag),
373 GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(open_tag));
374 grn_highlighter_add_close_tagcxx . . $ grn_highlighter_add_close_tag(fa1e26c9a0881d65).(ctx,
375 highlighter,
376 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(close_tag),
377 GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(close_tag));
378 }
379 }
380
381 highlighted = grn_plugin_proc_alloccxx . . $ grn_plugin_proc_alloc(acb267eca6702fc).(ctx, user_data, GRN_DB_TEXTcxx . . $ GRN_DB_TEXT., 0);
382 grn_highlighter_highlightcxx . . $ grn_highlighter_highlight(632d74b7a20d517f).(ctx,
383 highlighter,
384 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(string),
385 (int64_tcxx . . $ int64_t#)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(string),
386 highlighted);
387 }
388 #undef KEYWORD_SET_SIZEcxx . . $ `lib/proc/proc_highlight.c:281:9`!
389 #undef N_REQUIRED_ARGScxx . . $ `lib/proc/proc_highlight.c:280:9`!
390
391 exit:
392 if (!highlighted) {
393 highlighted = grn_plugin_proc_alloccxx . . $ grn_plugin_proc_alloc(acb267eca6702fc).(ctx, user_data, GRN_DB_VOIDcxx . . $ GRN_DB_VOID., 0);
394 }
395
396 return highlighted;
397 }
398
399 void
400 grn_proc_init_highlight_fullcxx . . $ grn_proc_init_highlight_full(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx)
401 {
402 grn_proc_createcxx . . $ grn_proc_create(195df001e5324f57).(ctx,
403 "highlight_full",
404 -1,
405 GRN_PROC_FUNCTIONcxx . . $ GRN_PROC_FUNCTION.,
406 func_highlight_fullcxx . . $ func_highlight_full(fd082858389c8bb0).,
407 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!,
408 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!,
409 0,
410 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!);
411 }
412
413 static grn_objcxx . . $ grn_obj# *
414 func_highlight_htmlcxx . . $ func_highlight_html(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx,
415 int nargs,
416 grn_objcxx . . $ grn_obj# **args,
417 grn_user_datacxx . . $ grn_user_data# *user_data)
418 {
419 const char *tag = "[highlight-html]";
420 const char *function_name = "highlight_html";
421
422 grn_objcxx . . $ grn_obj# *highlighted = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!;
423 grn_highlightercxx . . $ grn_highlighter# *highlighter = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!;
424 grn_objcxx . . $ grn_obj# *highlighter_ptr = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!;
425
426 if (!(1 <= nargs && nargs <= 2)) {
427 GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(
428 ctx,
429 GRN_INVALID_ARGUMENT,
430 "highlight_html(): wrong number of arguments (%d for 1..3)",
431 nargs);
432 highlighted = grn_plugin_proc_alloccxx . . $ grn_plugin_proc_alloc(acb267eca6702fc).(ctx, user_data, GRN_DB_VOIDcxx . . $ GRN_DB_VOID., 0);
433 return highlighted;
434 }
435
436 grn_objcxx . . $ grn_obj# *string = args[0];
437
438 grn_objcxx . . $ grn_obj# cache_key;
439 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&cache_key, 0);
440 grn_proc_func_generate_cache_keycxx . . $ grn_proc_func_generate_cache_key(1f5c90cc9be2f095).(ctx,
441 function_name,
442 args + 1,
443 nargs - 1,
444 &cache_key);
445
446 grn_objcxx . . $ grn_obj# *expression;
447 grn_proc_get_infocxx . . $ grn_proc_get_info(760bc9a52c80d02a).(ctx, user_data, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, &expression);
448
449 if (GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&cache_key) <= GRN_TABLE_MAX_KEY_SIZEcxx . . $ `include/groonga/table.h:26:9`!) {
450 highlighter_ptr = grn_expr_get_varcxx . . $ grn_expr_get_var(c00e49795c44129a).(ctx,
451 expression,
452 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&cache_key),
453 (unsigned int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&cache_key));
454 if (highlighter_ptr) {
455 highlighter = (grn_highlightercxx . . $ grn_highlighter# *)GRN_PTR_VALUEcxx . . $ `include/groonga/groonga.h:3111:9`!(highlighter_ptr);
456 } else {
457 highlighter_ptr =
458 grn_expr_get_or_add_varcxx . . $ grn_expr_get_or_add_var(c00e49795c44129a).(ctx,
459 expression,
460 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&cache_key),
461 (unsigned int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&cache_key));
462 if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESScxx . . $ GRN_SUCCESS.) {
463 goto exit;
464 }
465 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, highlighter_ptr);
466 GRN_PTR_INITcxx . . $ `include/groonga/groonga.h:2869:9`!(highlighter_ptr, GRN_OBJ_OWNcxx . . $ `include/groonga/groonga.h:945:9`!, GRN_DB_OBJECT);
467 }
468 }
469 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &cache_key);
470
471 if (!highlighter) {
472 highlighter = grn_highlighter_opencxx . . $ grn_highlighter_open(f7e87339fceabe42).(ctx);
473 if (highlighter_ptr) {
474 GRN_PTR_SETcxx . . $ `include/groonga/groonga.h:2945:9`!(ctx, highlighter_ptr, highlighter);
475 }
476
477 grn_objcxx . . $ grn_obj# *condition = grn_expr_get_conditioncxx . . $ grn_expr_get_condition(e9f40e4080908c1e).(ctx, expression);
478 for (; condition; condition = grn_expr_get_parentcxx . . $ grn_expr_get_parent(e9f40e4080908c1e).(ctx, condition)) {
479 uint32_tcxx . . $ uint32_t# i, n_keywords;
480 grn_objcxx . . $ grn_obj# current_keywords;
481 GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&current_keywords, GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!);
482 grn_expr_get_keywordscxx . . $ grn_expr_get_keywords(d825b4ed5bf12304).(ctx, condition, &current_keywords);
483
484 n_keywords = grn_vector_sizecxx . . $ grn_vector_size(8dd58acc9865e889).(ctx, &current_keywords);
485 for (i = 0; i < n_keywords; i++) {
486 const char *keyword;
487 unsigned int keyword_size;
488 keyword_size = grn_vector_get_elementcxx . . $ grn_vector_get_element(744613554bd9830c).(ctx,
489 &current_keywords,
490 i,
491 &keyword,
492 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!,
493 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!);
494 grn_highlighter_add_keywordcxx . . $ grn_highlighter_add_keyword(fa1e26c9a0881d65).(ctx, highlighter, keyword, keyword_size);
495 }
496 GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &current_keywords);
497 }
498
499 grn_objcxx . . $ grn_obj# *end_arg = args[nargs - 1];
500 int n_args_without_option = nargs;
501 if (grn_obj_is_tiny_hash_tablecxx . . $ grn_obj_is_tiny_hash_table(a5760e5c319a06ee).(ctx, end_arg)) {
502 n_args_without_option--;
503
504 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! sequential_class_tag_mode = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
505 grn_proc_options_parsecxx . . $ grn_proc_options_parse(b3b87877968531ef).(ctx,
506 end_arg,
507 tag,
508 "sequential_class_tag_mode",
509 GRN_PROC_OPTION_VALUE_BOOLcxx . . $ GRN_PROC_OPTION_VALUE_BOOL.,
510 &sequential_class_tag_mode,
511 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!);
512 if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESScxx . . $ GRN_SUCCESS.) {
513 goto exit;
514 }
515 grn_highlighter_set_sequential_class_tag_modecxx . . $ grn_highlighter_set_sequential_class_tag_mode(e400292976c965f5).(ctx,
516 highlighter,
517 sequential_class_tag_mode);
518 }
519
520 if (n_args_without_option == 2) {
521 grn_objcxx . . $ grn_obj# *lexicon = args[1];
522 grn_highlighter_set_lexiconcxx . . $ grn_highlighter_set_lexicon(7d1464b8c57e5d0b).(ctx, highlighter, lexicon);
523 }
524 }
525
526 highlighted = grn_plugin_proc_alloccxx . . $ grn_plugin_proc_alloc(acb267eca6702fc).(ctx, user_data, GRN_DB_TEXTcxx . . $ GRN_DB_TEXT., 0);
527 grn_highlighter_highlightcxx . . $ grn_highlighter_highlight(632d74b7a20d517f).(ctx,
528 highlighter,
529 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(string),
530 (int64_tcxx . . $ int64_t#)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(string),
531 highlighted);
532
533 exit:
534 if (!highlighted) {
535 highlighted = grn_plugin_proc_alloccxx . . $ grn_plugin_proc_alloc(acb267eca6702fc).(ctx, user_data, GRN_DB_VOIDcxx . . $ GRN_DB_VOID., 0);
536 }
537
538 return highlighted;
539 }
540
541 void
542 grn_proc_init_highlight_htmlcxx . . $ grn_proc_init_highlight_html(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx)
543 {
544 grn_proc_createcxx . . $ grn_proc_create(195df001e5324f57).(ctx,
545 "highlight_html",
546 -1,
547 GRN_PROC_FUNCTIONcxx . . $ GRN_PROC_FUNCTION.,
548 func_highlight_htmlcxx . . $ func_highlight_html(fd082858389c8bb0).,
549 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!,
550 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!,
551 0,
552 NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!);
553 }