| 296 | } match_regex_scan_cb_args; |
| 297 | |
| 298 | static int match_regex_scan_cb(int n, int pos, OnigRegion *region, void *arg) { |
| 299 | match_regex_scan_cb_args *args = (match_regex_scan_cb_args *)arg; |
| 300 | SIValue *list = args->list; |
| 301 | const char *str = args->str; |
| 302 | SIValue subList = SIArray_New(region->num_regs); |
| 303 | assert(region->num_regs > 0); |
| 304 | |
| 305 | for (int i = 0; i < region->num_regs; i++) { |
| 306 | int substr_len = region->end[i] - region->beg[i]; |
| 307 | char *substr = rm_strndup(str + region->beg[i], substr_len); |
| 308 | SIArray_Append(&subList, SI_TransferStringVal(substr)); |
| 309 | rm_free(substr); |
| 310 | } |
| 311 | |
| 312 | SIArray_Append(list, subList); |
| 313 | SIValue_Free(subList); |
| 314 | return 0; |
| 315 | } |
| 316 | |
| 317 | // given a string and a regular expression, |
| 318 | // return an array of all matches and matching regions |
nothing calls this directly
no test coverage detected