| 1 | /* |
| 2 | Copyright (C) 2016 Brazil |
| 3 | Copyright (C) 2020-2022 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 | #ifdef GRN_EMBEDDED |
| 21 | # define GRN_PLUGIN_FUNCTION_TAG functions_string |
| 22 | #endif |
| 23 | |
| 24 | #include <grn_onigmo.h>cxx . . $ `<file>/lib/grn_onigmo.h`/ |
| 25 | |
| 26 | #include <groonga/plugin.h>cxx . . $ `<file>/include/groonga/plugin.h`/ |
| 27 | |
| 28 | static int64_tcxx . . $ int64_t# |
| 29 | string_n_charscxx . . $ string_n_chars(3692066f1a5adcd0).(grn_ctxcxx . . $ grn_ctx# *ctx, const char *string, size_t string_size) |
| 30 | { |
| 31 | const char *p = string; |
| 32 | const char *end = string + string_size; |
| 33 | int64_tcxx . . $ int64_t# n_chars = 0; |
| 34 | int char_size = 0; |
| 35 | |
| 36 | for (; p < end && (char_size = grn_charlencxx . . $ grn_charlen(d229e8bf7c87f0f0).(ctx, p, end)); p += char_size) { |
| 37 | n_chars++; |
| 38 | } |
| 39 | |
| 40 | return n_chars; |
| 41 | } |
| 42 | |
| 43 | /* |
| 44 | * func_string_length() returns the number of characters in a string. |
| 45 | * If the string contains an invalid byte sequence, this function returns the |
| 46 | * number of characters before the invalid byte sequence. |
| 47 | */ |
| 48 | static grn_objcxx . . $ grn_obj# * |
| 49 | func_string_lengthcxx . . $ func_string_length(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 50 | int n_args, |
| 51 | grn_objcxx . . $ grn_obj# **args, |
| 52 | grn_user_datacxx . . $ grn_user_data# *user_data) |
| 53 | { |
| 54 | grn_objcxx . . $ grn_obj# *target; |
| 55 | unsigned int length = 0; |
| 56 | grn_objcxx . . $ grn_obj# *grn_length; |
| 57 | |
| 58 | if (n_args != 1) { |
| 59 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, |
| 60 | GRN_INVALID_ARGUMENT, |
| 61 | "string_length(): wrong number of arguments (%d for 1)", |
| 62 | n_args); |
| 63 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 64 | } |
| 65 | |
| 66 | target = args[0]; |
| 67 | if (!(target->headercxx . . $ _grn_obj#header..typecxx . . $ _grn_obj_header#type. == GRN_BULKcxx . . $ `include/groonga/groonga.h:868:9`! && |
| 68 | ((target->headercxx . . $ _grn_obj#header..domaincxx . . $ _grn_obj_header#domain. == GRN_DB_SHORT_TEXTcxx . . $ GRN_DB_SHORT_TEXT.) || |
| 69 | (target->headercxx . . $ _grn_obj#header..domaincxx . . $ _grn_obj_header#domain. == GRN_DB_TEXTcxx . . $ GRN_DB_TEXT.) || |
| 70 | (target->headercxx . . $ _grn_obj#header..domaincxx . . $ _grn_obj_header#domain. == GRN_DB_LONG_TEXTcxx . . $ GRN_DB_LONG_TEXT.)))) { |
| 71 | grn_objcxx . . $ grn_obj# inspected; |
| 72 | |
| 73 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&inspected, 0); |
| 74 | grn_inspectcxx . . $ grn_inspect(88456f97fe0d41a).(ctx, &inspected, target); |
| 75 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, |
| 76 | GRN_INVALID_ARGUMENT, |
| 77 | "string_length(): target object must be a text bulk: " |
| 78 | "<%.*s>", |
| 79 | (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&inspected), |
| 80 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&inspected)); |
| 81 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &inspected); |
| 82 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 83 | } |
| 84 | |
| 85 | length = string_n_charscxx . . $ string_n_chars(3692066f1a5adcd0).(ctx, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(target), GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(target)); |
| 86 | grn_length = grn_plugin_proc_alloccxx . . $ grn_plugin_proc_alloc(acb267eca6702fc).(ctx, user_data, GRN_DB_UINT32cxx . . $ GRN_DB_UINT32., 0); |
| 87 | if (!grn_length) { |
| 88 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 89 | } |
| 90 | |
| 91 | GRN_UINT32_SETcxx . . $ `include/groonga/groonga.h:2909:9`!(ctx, grn_length, length); |
| 92 | |
| 93 | return grn_length; |
| 94 | } |
| 95 | |
| 96 | static grn_objcxx . . $ grn_obj# * |
| 97 | func_string_substringcxx . . $ func_string_substring(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 98 | int n_args, |
| 99 | grn_objcxx . . $ grn_obj# **args, |
| 100 | grn_user_datacxx . . $ grn_user_data# *user_data) |
| 101 | { |
| 102 | #define string_substring_tagcxx . . $ `plugins/functions/string.c:102:9`! "[string_substring]" |
| 103 | |
| 104 | grn_objcxx . . $ grn_obj# *target; |
| 105 | grn_objcxx . . $ grn_obj# *from_raw; |
| 106 | grn_objcxx . . $ grn_obj# *length_raw = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 107 | grn_objcxx . . $ grn_obj# *default_value = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 108 | grn_objcxx . . $ grn_obj# *options = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 109 | int64_tcxx . . $ int64_t# from = 0; |
| 110 | int64_tcxx . . $ int64_t# length = -1; |
| 111 | const char *start = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 112 | const char *end = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 113 | grn_objcxx . . $ grn_obj# *substring = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 114 | |
| 115 | if (n_args < 2 || n_args > 4) { |
| 116 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, |
| 117 | GRN_INVALID_ARGUMENT, |
| 118 | "%s " |
| 119 | "wrong number of arguments (%d for 2..4)", |
| 120 | string_substring_tagcxx . . $ `plugins/functions/string.c:102:9`!, |
| 121 | n_args); |
| 122 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 123 | } |
| 124 | |
| 125 | target = args[0]; |
| 126 | from_raw = args[1]; |
| 127 | |
| 128 | if (n_args >= 3) { |
| 129 | grn_objcxx . . $ grn_obj# *length_or_options = args[2]; |
| 130 | if (grn_obj_is_number_family_bulkcxx . . $ grn_obj_is_number_family_bulk(a5760e5c319a06ee).(ctx, length_or_options)) { |
| 131 | length_raw = length_or_options; |
| 132 | } else if (length_or_options->headercxx . . $ _grn_obj#header..typecxx . . $ _grn_obj_header#type. == GRN_TABLE_HASH_KEYcxx . . $ `include/groonga/groonga.h:895:9`!) { |
| 133 | options = length_or_options; |
| 134 | } else { |
| 135 | grn_objcxx . . $ grn_obj# inspected; |
| 136 | |
| 137 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&inspected, 0); |
| 138 | grn_inspectcxx . . $ grn_inspect(88456f97fe0d41a).(ctx, &inspected, length_or_options); |
| 139 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, |
| 140 | GRN_INVALID_ARGUMENT, |
| 141 | "%s " |
| 142 | "3rd argument must be a long or a hash table: %.*s", |
| 143 | string_substring_tagcxx . . $ `plugins/functions/string.c:102:9`!, |
| 144 | (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&inspected), |
| 145 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&inspected)); |
| 146 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &inspected); |
| 147 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 148 | } |
| 149 | } |
| 150 | if (n_args == 4) { |
| 151 | // options type will be checked in grn_proc_options_parse |
| 152 | options = args[3]; |
| 153 | } |
| 154 | |
| 155 | if (options) { |
| 156 | grn_rccxx . . $ grn_rc# rc = grn_proc_options_parsecxx . . $ grn_proc_options_parse(b3b87877968531ef).(ctx, |
| 157 | options, |
| 158 | string_substring_tagcxx . . $ `plugins/functions/string.c:102:9`!, |
| 159 | "default_value", |
| 160 | GRN_PROC_OPTION_VALUE_RAWcxx . . $ GRN_PROC_OPTION_VALUE_RAW., |
| 161 | &default_value, |
| 162 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 163 | |
| 164 | if (rc != GRN_SUCCESScxx . . $ GRN_SUCCESS.) { |
| 165 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 166 | } |
| 167 | |
| 168 | if (default_value && !grn_obj_is_text_family_bulkcxx . . $ grn_obj_is_text_family_bulk(a5760e5c319a06ee).(ctx, default_value)) { |
| 169 | grn_objcxx . . $ grn_obj# inspected; |
| 170 | |
| 171 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&inspected, 0); |
| 172 | grn_inspectcxx . . $ grn_inspect(88456f97fe0d41a).(ctx, &inspected, default_value); |
| 173 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, |
| 174 | GRN_INVALID_ARGUMENT, |
| 175 | "%s[default_value] must be a text bulk: <%.*s>", |
| 176 | string_substring_tagcxx . . $ `plugins/functions/string.c:102:9`!, |
| 177 | (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&inspected), |
| 178 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&inspected)); |
| 179 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &inspected); |
| 180 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | if (!grn_obj_is_text_family_bulkcxx . . $ grn_obj_is_text_family_bulk(a5760e5c319a06ee).(ctx, target)) { |
| 185 | grn_objcxx . . $ grn_obj# inspected; |
| 186 | |
| 187 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&inspected, 0); |
| 188 | grn_inspectcxx . . $ grn_inspect(88456f97fe0d41a).(ctx, &inspected, target); |
| 189 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, |
| 190 | GRN_INVALID_ARGUMENT, |
| 191 | "%s[target] must be a text bulk: <%.*s>", |
| 192 | string_substring_tagcxx . . $ `plugins/functions/string.c:102:9`!, |
| 193 | (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&inspected), |
| 194 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&inspected)); |
| 195 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &inspected); |
| 196 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 197 | } |
| 198 | |
| 199 | from = grn_plugin_proc_get_value_int64cxx . . $ grn_plugin_proc_get_value_int64(7238b57f8c735d17).(ctx, |
| 200 | from_raw, |
| 201 | 0, |
| 202 | string_substring_tagcxx . . $ `plugins/functions/string.c:102:9`! "[from]"); |
| 203 | length = grn_plugin_proc_get_value_int64cxx . . $ grn_plugin_proc_get_value_int64(7238b57f8c735d17).(ctx, |
| 204 | length_raw, |
| 205 | -1, |
| 206 | string_substring_tagcxx . . $ `plugins/functions/string.c:102:9`! "[length]"); |
| 207 | |
| 208 | if (GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(target) == 0) { |
| 209 | goto exit; |
| 210 | } |
| 211 | if (length == 0) { |
| 212 | return grn_plugin_proc_alloccxx . . $ grn_plugin_proc_alloc(acb267eca6702fc).(ctx, user_data, target->headercxx . . $ _grn_obj#header..domaincxx . . $ _grn_obj_header#domain., 0); |
| 213 | } |
| 214 | |
| 215 | while (from < 0) { |
| 216 | from += (int64_tcxx . . $ int64_t#)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(target); |
| 217 | } |
| 218 | |
| 219 | { |
| 220 | const char *p; |
| 221 | |
| 222 | start = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 223 | p = GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(target); |
| 224 | end = p + GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(target); |
| 225 | |
| 226 | if (from == 0) { |
| 227 | start = p; |
| 228 | } else { |
| 229 | int char_length = 0; |
| 230 | size_t n_chars = 0; |
| 231 | |
| 232 | for (; p < end && (char_length = grn_charlencxx . . $ grn_charlen(d229e8bf7c87f0f0).(ctx, p, end)); |
| 233 | p += char_length, n_chars++) { |
| 234 | if (n_chars == (size_t)from) { |
| 235 | start = p; |
| 236 | break; |
| 237 | } |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | if (start && length > 0) { |
| 242 | int char_length = 0; |
| 243 | size_t n_chars = 0; |
| 244 | |
| 245 | for (; p < end && (char_length = grn_charlencxx . . $ grn_charlen(d229e8bf7c87f0f0).(ctx, p, end)); |
| 246 | p += char_length, n_chars++) { |
| 247 | if (n_chars == (size_t)length) { |
| 248 | end = p; |
| 249 | break; |
| 250 | } |
| 251 | } |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | if (start) { |
| 256 | substring = grn_plugin_proc_alloccxx . . $ grn_plugin_proc_alloc(acb267eca6702fc).(ctx, user_data, target->headercxx . . $ _grn_obj#header..domaincxx . . $ _grn_obj_header#domain., 0); |
| 257 | if (!substring) { |
| 258 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 259 | } |
| 260 | GRN_TEXT_SETcxx . . $ `include/groonga/groonga.h:2761:9`!(ctx, substring, start, end - start); |
| 261 | } |
| 262 | |
| 263 | exit: |
| 264 | |
| 265 | if (!substring) { |
| 266 | if (!default_value) { |
| 267 | default_value = |
| 268 | grn_plugin_proc_alloccxx . . $ grn_plugin_proc_alloc(acb267eca6702fc).(ctx, user_data, target->headercxx . . $ _grn_obj#header..domaincxx . . $ _grn_obj_header#domain., 0); |
| 269 | if (!default_value) { |
| 270 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 271 | } |
| 272 | } |
| 273 | substring = default_value; |
| 274 | } else if (GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(substring) == 0 && default_value) { |
| 275 | substring = default_value; |
| 276 | } |
| 277 | |
| 278 | return substring; |
| 279 | #undef string_substring_tagcxx . . $ `plugins/functions/string.c:102:9`! |
| 280 | } |
| 281 | |
| 282 | static boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! |
| 283 | string_is_over_n_charscxx . . $ string_is_over_n_chars(3c073fe412a716d8).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 284 | const char *string, |
| 285 | size_t string_size, |
| 286 | int64_tcxx . . $ int64_t# max_n_chars, |
| 287 | int64_tcxx . . $ int64_t# n_keep_chars, |
| 288 | const char **kept_end) |
| 289 | { |
| 290 | const char *p = string; |
| 291 | const char *end = string + string_size; |
| 292 | int64_tcxx . . $ int64_t# n_chars = 0; |
| 293 | int char_size = 0; |
| 294 | |
| 295 | *kept_end = string; |
| 296 | for (; p < end && (char_size = grn_charlencxx . . $ grn_charlen(d229e8bf7c87f0f0).(ctx, p, end)); p += char_size) { |
| 297 | n_chars++; |
| 298 | if (n_chars == n_keep_chars) { |
| 299 | *kept_end = p + char_size; |
| 300 | } |
| 301 | if (n_chars > max_n_chars) { |
| 302 | return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 303 | } |
| 304 | } |
| 305 | return falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 306 | } |
| 307 | |
| 308 | /* |
| 309 | * func_string_truncate() truncates a string to at most `length` characters. |
| 310 | * If truncation occurs, the tail of the kept portion is replaced so that the |
| 311 | * result (kept portion + omission) is `length` characters long, in the same |
| 312 | * way as Ruby on Rails' String#truncate. |
| 313 | * |
| 314 | * Note: |
| 315 | * If `omission` itself is longer than `length`, the result is `omission` alone. |
| 316 | * This is the same as Ruby on Rails' String#truncate. |
| 317 | */ |
| 318 | static grn_objcxx . . $ grn_obj# * |
| 319 | func_string_truncatecxx . . $ func_string_truncate(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 320 | int n_args, |
| 321 | grn_objcxx . . $ grn_obj# **args, |
| 322 | grn_user_datacxx . . $ grn_user_data# *user_data) |
| 323 | { |
| 324 | #define string_truncate_tagcxx . . $ `plugins/functions/string.c:324:9`! "[string_truncate]" |
| 325 | |
| 326 | if (n_args < 2 || n_args > 3) { |
| 327 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, |
| 328 | GRN_INVALID_ARGUMENT, |
| 329 | "%s " |
| 330 | "wrong number of arguments (%d for 2..3)", |
| 331 | string_truncate_tagcxx . . $ `plugins/functions/string.c:324:9`!, |
| 332 | n_args); |
| 333 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 334 | } |
| 335 | |
| 336 | grn_objcxx . . $ grn_obj# *target = args[0]; |
| 337 | grn_objcxx . . $ grn_obj# *options = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 338 | if (n_args == 3) { |
| 339 | options = args[2]; |
| 340 | } |
| 341 | |
| 342 | if (!grn_obj_is_text_family_bulkcxx . . $ grn_obj_is_text_family_bulk(a5760e5c319a06ee).(ctx, target)) { |
| 343 | grn_objcxx . . $ grn_obj# inspected; |
| 344 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&inspected, 0); |
| 345 | grn_inspectcxx . . $ grn_inspect(88456f97fe0d41a).(ctx, &inspected, target); |
| 346 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, |
| 347 | GRN_INVALID_ARGUMENT, |
| 348 | "%s[target] must be a text bulk: <%.*s>", |
| 349 | string_truncate_tagcxx . . $ `plugins/functions/string.c:324:9`!, |
| 350 | (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&inspected), |
| 351 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&inspected)); |
| 352 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &inspected); |
| 353 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 354 | } |
| 355 | |
| 356 | grn_objcxx . . $ grn_obj# *omission = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 357 | if (options) { |
| 358 | grn_rccxx . . $ grn_rc# rc = grn_proc_options_parsecxx . . $ grn_proc_options_parse(b3b87877968531ef).(ctx, |
| 359 | options, |
| 360 | string_truncate_tagcxx . . $ `plugins/functions/string.c:324:9`!, |
| 361 | "omission", |
| 362 | GRN_PROC_OPTION_VALUE_RAWcxx . . $ GRN_PROC_OPTION_VALUE_RAW., |
| 363 | &omission, |
| 364 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 365 | |
| 366 | if (rc != GRN_SUCCESScxx . . $ GRN_SUCCESS.) { |
| 367 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 368 | } |
| 369 | |
| 370 | if (omission && !grn_obj_is_text_family_bulkcxx . . $ grn_obj_is_text_family_bulk(a5760e5c319a06ee).(ctx, omission)) { |
| 371 | grn_objcxx . . $ grn_obj# inspected; |
| 372 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&inspected, 0); |
| 373 | grn_inspectcxx . . $ grn_inspect(88456f97fe0d41a).(ctx, &inspected, omission); |
| 374 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, |
| 375 | GRN_INVALID_ARGUMENT, |
| 376 | "%s[omission] must be a text bulk: <%.*s>", |
| 377 | string_truncate_tagcxx . . $ `plugins/functions/string.c:324:9`!, |
| 378 | (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&inspected), |
| 379 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&inspected)); |
| 380 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &inspected); |
| 381 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | int64_tcxx . . $ int64_t# max_n_chars = |
| 386 | grn_plugin_proc_get_value_int64cxx . . $ grn_plugin_proc_get_value_int64(7238b57f8c735d17).(ctx, |
| 387 | args[1], |
| 388 | 0, |
| 389 | string_truncate_tagcxx . . $ `plugins/functions/string.c:324:9`! "[length]"); |
| 390 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESScxx . . $ GRN_SUCCESS.) { |
| 391 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 392 | } |
| 393 | |
| 394 | const char *omission_value = "..."; |
| 395 | size_t omission_size = 3; |
| 396 | int64_tcxx . . $ int64_t# n_omission_chars = 3; |
| 397 | if (omission) { |
| 398 | omission_value = GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(omission); |
| 399 | omission_size = GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(omission); |
| 400 | n_omission_chars = string_n_charscxx . . $ string_n_chars(3692066f1a5adcd0).(ctx, omission_value, omission_size); |
| 401 | } |
| 402 | |
| 403 | grn_objcxx . . $ grn_obj# *result = |
| 404 | grn_plugin_proc_alloccxx . . $ grn_plugin_proc_alloc(acb267eca6702fc).(ctx, user_data, target->headercxx . . $ _grn_obj#header..domaincxx . . $ _grn_obj_header#domain., 0); |
| 405 | if (!result) { |
| 406 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 407 | } |
| 408 | if (max_n_chars < 0) { |
| 409 | GRN_TEXT_SETcxx . . $ `include/groonga/groonga.h:2761:9`!(ctx, result, omission_value, omission_size); |
| 410 | return result; |
| 411 | } |
| 412 | |
| 413 | int64_tcxx . . $ int64_t# n_keep_chars = max_n_chars - n_omission_chars; |
| 414 | if (n_keep_chars < 0) { |
| 415 | n_keep_chars = 0; |
| 416 | } |
| 417 | const char *kept_end = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 418 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! is_over = string_is_over_n_charscxx . . $ string_is_over_n_chars(3c073fe412a716d8).(ctx, |
| 419 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(target), |
| 420 | GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(target), |
| 421 | max_n_chars, |
| 422 | n_keep_chars, |
| 423 | &kept_end); |
| 424 | if (!is_over) { |
| 425 | GRN_TEXT_SETcxx . . $ `include/groonga/groonga.h:2761:9`!(ctx, result, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(target), GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(target)); |
| 426 | return result; |
| 427 | } |
| 428 | |
| 429 | const char *kept_start = GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(target); |
| 430 | GRN_TEXT_SETcxx . . $ `include/groonga/groonga.h:2761:9`!(ctx, result, kept_start, kept_end - kept_start); |
| 431 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, result, omission_value, omission_size); |
| 432 | return result; |
| 433 | #undef string_truncate_tagcxx . . $ `plugins/functions/string.c:324:9`! |
| 434 | } |
| 435 | |
| 436 | static grn_objcxx . . $ grn_obj# * |
| 437 | func_string_tokenizecxx . . $ func_string_tokenize(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 438 | int n_args, |
| 439 | grn_objcxx . . $ grn_obj# **args, |
| 440 | grn_user_datacxx . . $ grn_user_data# *user_data) |
| 441 | { |
| 442 | grn_objcxx . . $ grn_obj# *target; |
| 443 | grn_objcxx . . $ grn_obj# *lexicon; |
| 444 | grn_objcxx . . $ grn_obj# *options = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 445 | |
| 446 | if (!(n_args == 2 || n_args == 3)) { |
| 447 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!( |
| 448 | ctx, |
| 449 | GRN_INVALID_ARGUMENT, |
| 450 | "[string_tokenize] wrong number of arguments (%d for 2..3)", |
| 451 | n_args); |
| 452 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 453 | } |
| 454 | |
| 455 | target = args[0]; |
| 456 | lexicon = args[1]; |
| 457 | if (n_args == 3) { |
| 458 | options = args[2]; |
| 459 | } |
| 460 | |
| 461 | if (!grn_obj_is_text_family_bulkcxx . . $ grn_obj_is_text_family_bulk(a5760e5c319a06ee).(ctx, target)) { |
| 462 | grn_objcxx . . $ grn_obj# inspected; |
| 463 | |
| 464 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&inspected, 0); |
| 465 | grn_inspectcxx . . $ grn_inspect(88456f97fe0d41a).(ctx, &inspected, target); |
| 466 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, |
| 467 | GRN_INVALID_ARGUMENT, |
| 468 | "[string_tokenize][target] must be a text bulk: %.*s", |
| 469 | (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&inspected), |
| 470 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&inspected)); |
| 471 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &inspected); |
| 472 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 473 | } |
| 474 | |
| 475 | if (!grn_obj_is_table_with_keycxx . . $ grn_obj_is_table_with_key(a5760e5c319a06ee).(ctx, lexicon)) { |
| 476 | grn_objcxx . . $ grn_obj# inspected; |
| 477 | |
| 478 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&inspected, 0); |
| 479 | grn_inspectcxx . . $ grn_inspect(88456f97fe0d41a).(ctx, &inspected, lexicon); |
| 480 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!( |
| 481 | ctx, |
| 482 | GRN_INVALID_ARGUMENT, |
| 483 | "[string_tokenize][lexicon] must be a table with key: %.*s", |
| 484 | (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&inspected), |
| 485 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&inspected)); |
| 486 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &inspected); |
| 487 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 488 | } |
| 489 | |
| 490 | grn_tokenize_modecxx . . $ grn_tokenize_mode# mode = GRN_TOKEN_GETcxx . . $ `include/groonga/token.h:58:9`!; |
| 491 | uint32_tcxx . . $ uint32_t# flags = 0; |
| 492 | if (options) { |
| 493 | grn_rccxx . . $ grn_rc# rc = grn_proc_options_parsecxx . . $ grn_proc_options_parse(b3b87877968531ef).(ctx, |
| 494 | options, |
| 495 | "[string_tokenize]", |
| 496 | "mode", |
| 497 | GRN_PROC_OPTION_VALUE_TOKENIZE_MODEcxx . . $ GRN_PROC_OPTION_VALUE_TOKENIZE_MODE., |
| 498 | &mode, |
| 499 | "flags", |
| 500 | GRN_PROC_OPTION_VALUE_TOKEN_CURSOR_FLAGScxx . . $ GRN_PROC_OPTION_VALUE_TOKEN_CURSOR_FLAGS., |
| 501 | &flags, |
| 502 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 503 | if (rc != GRN_SUCCESScxx . . $ GRN_SUCCESS.) { |
| 504 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | grn_objcxx . . $ grn_obj# *tokens = grn_plugin_proc_alloccxx . . $ grn_plugin_proc_alloc(acb267eca6702fc).(ctx, |
| 509 | user_data, |
| 510 | grn_obj_idcxx . . $ grn_obj_id(8dd58acc9865e889).(ctx, lexicon), |
| 511 | GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!); |
| 512 | if (!tokens) { |
| 513 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 514 | } |
| 515 | tokens->headercxx . . $ _grn_obj#header..flagscxx . . $ _grn_obj_header#flags. |= GRN_OBJ_WITH_WEIGHTcxx . . $ `include/groonga/groonga.h:785:9`!; |
| 516 | |
| 517 | grn_token_cursorcxx . . $ grn_token_cursor# *token_cursor; |
| 518 | token_cursor = grn_token_cursor_opencxx . . $ grn_token_cursor_open(b521006a1987c493).(ctx, |
| 519 | lexicon, |
| 520 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(target), |
| 521 | GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(target), |
| 522 | mode, |
| 523 | flags); |
| 524 | if (!token_cursor) { |
| 525 | return tokens; |
| 526 | } |
| 527 | while (grn_token_cursor_get_statuscxx . . $ grn_token_cursor_get_status(4be9deca176a28c7).(ctx, token_cursor) == |
| 528 | GRN_TOKEN_CURSOR_DOINGcxx . . $ GRN_TOKEN_CURSOR_DOING.) { |
| 529 | grn_idcxx . . $ grn_id# token_id = grn_token_cursor_nextcxx . . $ grn_token_cursor_next(60c29d5cf5463368).(ctx, token_cursor); |
| 530 | |
| 531 | if (token_id == GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!) { |
| 532 | continue; |
| 533 | } |
| 534 | |
| 535 | grn_tokencxx . . $ grn_token# *token = grn_token_cursor_get_tokencxx . . $ grn_token_cursor_get_token(42eb6886c4ba0dd1).(ctx, token_cursor); |
| 536 | float weight = grn_token_get_weightcxx . . $ grn_token_get_weight(92787578964708a1).(ctx, token); |
| 537 | grn_uvector_add_element_recordcxx . . $ grn_uvector_add_element_record(bb4e215c5fe2bb23).(ctx, tokens, token_id, weight); |
| 538 | } |
| 539 | grn_token_cursor_closecxx . . $ grn_token_cursor_close(fbd52f00bdc6c9ff).(ctx, token_cursor); |
| 540 | |
| 541 | return tokens; |
| 542 | } |
| 543 | |
| 544 | static grn_objcxx . . $ grn_obj# * |
| 545 | string_regexp_slicecxx . . $ string_regexp_slice(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 546 | int n_args, |
| 547 | grn_objcxx . . $ grn_obj# **args, |
| 548 | grn_user_datacxx . . $ grn_user_data# *user_data) |
| 549 | { |
| 550 | #ifdef GRN_SUPPORT_REGEXPcxx . . $ `lib/grn.h:734:11`! |
| 551 | # define string_regexp_slice_tagcxx . . $ `plugins/functions/string.c:551:11`! "[string_slice]" |
| 552 | |
| 553 | grn_objcxx . . $ grn_obj# *target_raw, *pattern, *nth_or_name, *default_value = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, |
| 554 | *result = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 555 | |
| 556 | if (!(n_args == 3 || n_args == 4)) { |
| 557 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, |
| 558 | GRN_INVALID_ARGUMENT, |
| 559 | "%s wrong number of arguments (%d for 3...4)", |
| 560 | string_regexp_slice_tagcxx . . $ `plugins/functions/string.c:551:11`!, |
| 561 | n_args); |
| 562 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 563 | } |
| 564 | |
| 565 | target_raw = args[0]; |
| 566 | pattern = args[1]; |
| 567 | nth_or_name = args[2]; |
| 568 | |
| 569 | if (n_args == 4) { |
| 570 | grn_objcxx . . $ grn_obj# *options = args[3]; |
| 571 | grn_rccxx . . $ grn_rc# rc = grn_proc_options_parsecxx . . $ grn_proc_options_parse(b3b87877968531ef).(ctx, |
| 572 | options, |
| 573 | string_regexp_slice_tagcxx . . $ `plugins/functions/string.c:551:11`!, |
| 574 | "default_value", |
| 575 | GRN_PROC_OPTION_VALUE_RAWcxx . . $ GRN_PROC_OPTION_VALUE_RAW., |
| 576 | &default_value, |
| 577 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 578 | |
| 579 | if (rc != GRN_SUCCESScxx . . $ GRN_SUCCESS.) { |
| 580 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 581 | } |
| 582 | |
| 583 | if (default_value && !grn_obj_is_text_family_bulkcxx . . $ grn_obj_is_text_family_bulk(a5760e5c319a06ee).(ctx, default_value)) { |
| 584 | grn_objcxx . . $ grn_obj# inspected; |
| 585 | |
| 586 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&inspected, 0); |
| 587 | grn_inspectcxx . . $ grn_inspect(88456f97fe0d41a).(ctx, &inspected, default_value); |
| 588 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, |
| 589 | GRN_INVALID_ARGUMENT, |
| 590 | "%s[default_value] must be a text bulk: <%.*s>", |
| 591 | string_regexp_slice_tagcxx . . $ `plugins/functions/string.c:551:11`!, |
| 592 | (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&inspected), |
| 593 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&inspected)); |
| 594 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &inspected); |
| 595 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 596 | } |
| 597 | } |
| 598 | |
| 599 | if (!grn_obj_is_text_family_bulkcxx . . $ grn_obj_is_text_family_bulk(a5760e5c319a06ee).(ctx, nth_or_name) && |
| 600 | !grn_obj_is_number_family_bulkcxx . . $ grn_obj_is_number_family_bulk(a5760e5c319a06ee).(ctx, nth_or_name)) { |
| 601 | grn_objcxx . . $ grn_obj# inspected; |
| 602 | |
| 603 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&inspected, 0); |
| 604 | grn_inspectcxx . . $ grn_inspect(88456f97fe0d41a).(ctx, &inspected, nth_or_name); |
| 605 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, |
| 606 | GRN_INVALID_ARGUMENT, |
| 607 | "%s[nth_or_name] must be a text or number bulk: %.*s", |
| 608 | string_regexp_slice_tagcxx . . $ `plugins/functions/string.c:551:11`!, |
| 609 | (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&inspected), |
| 610 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&inspected)); |
| 611 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &inspected); |
| 612 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 613 | } |
| 614 | |
| 615 | // TODO: should cache |
| 616 | OnigRegexcxx . . $ OnigRegex# regexp = grn_onigmo_newcxx . . $ grn_onigmo_new(5d4bcbb55fe07878).(ctx, |
| 617 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(pattern), |
| 618 | GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(pattern), |
| 619 | GRN_ONIGMO_OPTION_DEFAULTcxx . . $ `lib/grn_onigmo.h:33:9`!, |
| 620 | GRN_ONIGMO_SYNTAX_DEFAULTcxx . . $ `lib/grn_onigmo.h:37:9`!, |
| 621 | string_regexp_slice_tagcxx . . $ `plugins/functions/string.c:551:11`! "[regexp]"); |
| 622 | |
| 623 | if (!regexp) { |
| 624 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 625 | } |
| 626 | |
| 627 | const char *target = GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(target_raw); |
| 628 | size_t target_length = GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(target_raw); |
| 629 | |
| 630 | OnigRegioncxx . . $ OnigRegion# region; |
| 631 | onig_region_initcxx . . $ onig_region_init(46e0b3918c7f0f64).(®ion); |
| 632 | |
| 633 | // Cannot use normalized string. |
| 634 | // The matching parts of the original string cannot be inferred from the |
| 635 | // matching parts of the normalized string. |
| 636 | OnigPositioncxx . . $ OnigPosition# position = onig_searchcxx . . $ onig_search(68be31d4a4ee5023).(regexp, |
| 637 | target, |
| 638 | target + target_length, |
| 639 | target, |
| 640 | target + target_length, |
| 641 | ®ion, |
| 642 | ONIG_OPTION_NONEcxx . . $ `vendor/onigmo-source/onigmo.h:450:9`!); |
| 643 | |
| 644 | if (position != ONIG_MISMATCHcxx . . $ `vendor/onigmo-source/onigmo.h:625:9`!) { |
| 645 | int64_tcxx . . $ int64_t# nth = -1; |
| 646 | |
| 647 | if (grn_obj_is_text_family_bulkcxx . . $ grn_obj_is_text_family_bulk(a5760e5c319a06ee).(ctx, nth_or_name)) { |
| 648 | const char *name = GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(nth_or_name); |
| 649 | size_t name_length = GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(nth_or_name); |
| 650 | |
| 651 | nth = |
| 652 | onig_name_to_backref_numbercxx . . $ onig_name_to_backref_number(5ee092671d60807c).(regexp, name, name + name_length, ®ion); |
| 653 | |
| 654 | } else if (grn_obj_is_number_family_bulkcxx . . $ grn_obj_is_number_family_bulk(a5760e5c319a06ee).(ctx, nth_or_name)) { |
| 655 | nth = grn_plugin_proc_get_value_int64cxx . . $ grn_plugin_proc_get_value_int64(7238b57f8c735d17).(ctx, |
| 656 | nth_or_name, |
| 657 | 0, |
| 658 | string_regexp_slice_tagcxx . . $ `plugins/functions/string.c:551:11`! "[nth]"); |
| 659 | } |
| 660 | |
| 661 | if (nth >= 0 && nth < region.num_regscxx . . $ re_registers#num_regs.) { |
| 662 | OnigPositioncxx . . $ OnigPosition# start = region.begcxx . . $ re_registers#beg.[nth]; |
| 663 | OnigPositioncxx . . $ OnigPosition# end = region.endcxx . . $ re_registers#end.[nth]; |
| 664 | |
| 665 | result = |
| 666 | grn_plugin_proc_alloccxx . . $ grn_plugin_proc_alloc(acb267eca6702fc).(ctx, user_data, target_raw->headercxx . . $ _grn_obj#header..domaincxx . . $ _grn_obj_header#domain., 0); |
| 667 | if (!result) { |
| 668 | goto exit; |
| 669 | } |
| 670 | GRN_TEXT_SETcxx . . $ `include/groonga/groonga.h:2761:9`!(ctx, result, target + start, end - start); |
| 671 | } |
| 672 | } |
| 673 | |
| 674 | if (!result) { |
| 675 | if (!default_value) { |
| 676 | default_value = |
| 677 | grn_plugin_proc_alloccxx . . $ grn_plugin_proc_alloc(acb267eca6702fc).(ctx, user_data, target_raw->headercxx . . $ _grn_obj#header..domaincxx . . $ _grn_obj_header#domain., 0); |
| 678 | if (!default_value) { |
| 679 | goto exit; |
| 680 | } |
| 681 | } |
| 682 | result = default_value; |
| 683 | } |
| 684 | |
| 685 | exit: |
| 686 | |
| 687 | onig_region_freecxx . . $ onig_region_free(f7147865f954e3eb).(®ion, 0); |
| 688 | onig_freecxx . . $ onig_free(b1814a8fd6af504b).(regexp); |
| 689 | |
| 690 | return result; |
| 691 | # undef string_regexp_slice_tagcxx . . $ `plugins/functions/string.c:551:11`! |
| 692 | #else // GRN_SUPPORT_REGEXP |
| 693 | return NULL; |
| 694 | #endif // GRN_SUPPORT_REGEXP |
| 695 | } |
| 696 | |
| 697 | static grn_objcxx . . $ grn_obj# * |
| 698 | func_string_slicecxx . . $ func_string_slice(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 699 | int n_args, |
| 700 | grn_objcxx . . $ grn_obj# **args, |
| 701 | grn_user_datacxx . . $ grn_user_data# *user_data) |
| 702 | { |
| 703 | const char *tag = "[string_slice]"; |
| 704 | |
| 705 | if (n_args < 2 || n_args > 4) { |
| 706 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, |
| 707 | GRN_INVALID_ARGUMENT, |
| 708 | "%s " |
| 709 | "wrong number of arguments (%d for 2..4)", |
| 710 | tag, |
| 711 | n_args); |
| 712 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 713 | } |
| 714 | |
| 715 | if (grn_obj_is_number_family_bulkcxx . . $ grn_obj_is_number_family_bulk(a5760e5c319a06ee).(ctx, args[1])) { |
| 716 | if (n_args >= 3) { |
| 717 | return func_string_substringcxx . . $ func_string_substring(fd082858389c8bb0).(ctx, n_args, args, user_data); |
| 718 | } |
| 719 | |
| 720 | grn_objcxx . . $ grn_obj# *new_args[3]; |
| 721 | grn_objcxx . . $ grn_obj# third_arg; |
| 722 | grn_objcxx . . $ grn_obj# *result; |
| 723 | |
| 724 | GRN_INT64_INITcxx . . $ `include/groonga/groonga.h:2856:9`!(&third_arg, 0); |
| 725 | GRN_INT64_SETcxx . . $ `include/groonga/groonga.h:2914:9`!(ctx, &third_arg, 1); |
| 726 | |
| 727 | new_args[0] = args[0]; |
| 728 | new_args[1] = args[1]; |
| 729 | new_args[2] = &third_arg; |
| 730 | |
| 731 | result = func_string_substringcxx . . $ func_string_substring(fd082858389c8bb0).(ctx, 3, new_args, user_data); |
| 732 | |
| 733 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &third_arg); |
| 734 | |
| 735 | return result; |
| 736 | } else if (grn_obj_is_text_family_bulkcxx . . $ grn_obj_is_text_family_bulk(a5760e5c319a06ee).(ctx, args[1])) { |
| 737 | return string_regexp_slicecxx . . $ string_regexp_slice(fd082858389c8bb0).(ctx, n_args, args, user_data); |
| 738 | } else { |
| 739 | grn_objcxx . . $ grn_obj# inspected; |
| 740 | |
| 741 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&inspected, 0); |
| 742 | grn_inspectcxx . . $ grn_inspect(88456f97fe0d41a).(ctx, &inspected, args[1]); |
| 743 | GRN_PLUGIN_ERRORcxx . . $ `include/groonga/plugin.h:145:9`!(ctx, |
| 744 | GRN_INVALID_ARGUMENT, |
| 745 | "%s " |
| 746 | "2nd argument must be a text or number bulk: %.*s", |
| 747 | tag, |
| 748 | (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&inspected), |
| 749 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&inspected)); |
| 750 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &inspected); |
| 751 | |
| 752 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 753 | } |
| 754 | } |
| 755 | |
| 756 | grn_rccxx . . $ grn_rc# |
| 757 | GRN_PLUGIN_INITcxx . . $ `include/groonga/plugin.h:43:9`!(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 758 | { |
| 759 | return ctx->rccxx . . $ _grn_ctx#rc.; |
| 760 | } |
| 761 | |
| 762 | grn_rccxx . . $ grn_rc# |
| 763 | GRN_PLUGIN_REGISTERcxx . . $ `include/groonga/plugin.h:44:9`!(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 764 | { |
| 765 | grn_rccxx . . $ grn_rc# rc = GRN_SUCCESScxx . . $ GRN_SUCCESS.; |
| 766 | |
| 767 | grn_proc_createcxx . . $ grn_proc_create(195df001e5324f57).(ctx, |
| 768 | "string_length", |
| 769 | -1, |
| 770 | GRN_PROC_FUNCTIONcxx . . $ GRN_PROC_FUNCTION., |
| 771 | func_string_lengthcxx . . $ func_string_length(fd082858389c8bb0)., |
| 772 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, |
| 773 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, |
| 774 | 0, |
| 775 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 776 | |
| 777 | grn_proc_createcxx . . $ grn_proc_create(195df001e5324f57).(ctx, |
| 778 | "string_substring", |
| 779 | -1, |
| 780 | GRN_PROC_FUNCTIONcxx . . $ GRN_PROC_FUNCTION., |
| 781 | func_string_substringcxx . . $ func_string_substring(fd082858389c8bb0)., |
| 782 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, |
| 783 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, |
| 784 | 0, |
| 785 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 786 | |
| 787 | grn_proc_createcxx . . $ grn_proc_create(195df001e5324f57).(ctx, |
| 788 | "string_truncate", |
| 789 | -1, |
| 790 | GRN_PROC_FUNCTIONcxx . . $ GRN_PROC_FUNCTION., |
| 791 | func_string_truncatecxx . . $ func_string_truncate(fd082858389c8bb0)., |
| 792 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, |
| 793 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, |
| 794 | 0, |
| 795 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 796 | |
| 797 | grn_proc_createcxx . . $ grn_proc_create(195df001e5324f57).(ctx, |
| 798 | "string_tokenize", |
| 799 | -1, |
| 800 | GRN_PROC_FUNCTIONcxx . . $ GRN_PROC_FUNCTION., |
| 801 | func_string_tokenizecxx . . $ func_string_tokenize(fd082858389c8bb0)., |
| 802 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, |
| 803 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, |
| 804 | 0, |
| 805 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 806 | |
| 807 | grn_proc_createcxx . . $ grn_proc_create(195df001e5324f57).(ctx, |
| 808 | "string_slice", |
| 809 | -1, |
| 810 | GRN_PROC_FUNCTIONcxx . . $ GRN_PROC_FUNCTION., |
| 811 | func_string_slicecxx . . $ func_string_slice(fd082858389c8bb0)., |
| 812 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, |
| 813 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, |
| 814 | 0, |
| 815 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 816 | |
| 817 | return rc; |
| 818 | } |
| 819 | |
| 820 | grn_rccxx . . $ grn_rc# |
| 821 | GRN_PLUGIN_FINcxx . . $ `include/groonga/plugin.h:45:9`!(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 822 | { |
| 823 | return GRN_SUCCESScxx . . $ GRN_SUCCESS.; |
| 824 | } |