MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / match_regex_scan_cb

Function match_regex_scan_cb

src/arithmetic/string_funcs/string_funcs.c:298–315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

296} match_regex_scan_cb_args;
297
298static 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

Callers

nothing calls this directly

Calls 6

SIArray_NewFunction · 0.85
rm_strndupFunction · 0.85
SIArray_AppendFunction · 0.85
SI_TransferStringValFunction · 0.85
rm_freeFunction · 0.85
SIValue_FreeFunction · 0.85

Tested by

no test coverage detected