| 37 | } |
| 38 | |
| 39 | int cbm_regexec(const cbm_regex_t *r, const char *str, int nmatch, cbm_regmatch_t *matches, |
| 40 | int eflags) { |
| 41 | const regex_t *re = (const regex_t *)r->opaque; |
| 42 | if (nmatch <= 0 || !matches) { |
| 43 | int rc = tre_regexec(re, str, 0, NULL, eflags); |
| 44 | return rc == 0 ? CBM_REG_OK : CBM_REG_NOMATCH; |
| 45 | } |
| 46 | regmatch_t pmatch[CBM_SZ_32]; |
| 47 | int n = nmatch > CBM_SZ_32 ? CBM_SZ_32 : nmatch; |
| 48 | int rc = tre_regexec(re, str, (size_t)n, pmatch, eflags); |
| 49 | if (rc != 0) |
| 50 | return CBM_REG_NOMATCH; |
| 51 | for (int i = 0; i < n; i++) { |
| 52 | matches[i].rm_so = (int)pmatch[i].rm_so; |
| 53 | matches[i].rm_eo = (int)pmatch[i].rm_eo; |
| 54 | } |
| 55 | return CBM_REG_OK; |
| 56 | } |
| 57 | |
| 58 | void cbm_regfree(cbm_regex_t *r) { |
| 59 | regex_t *re = (regex_t *)r->opaque; |
no outgoing calls
no test coverage detected