| 32 | using swoc::Rv; |
| 33 | |
| 34 | Rv<Rxp> |
| 35 | Rxp::parse(TextView const &str, Options const &options) |
| 36 | { |
| 37 | int errc = 0; |
| 38 | size_t err_off = 0; |
| 39 | uint32_t rxp_opt = 0; |
| 40 | if (options.f.nc) { |
| 41 | rxp_opt = PCRE2_CASELESS; |
| 42 | } |
| 43 | auto result = pcre2_compile(reinterpret_cast<unsigned const char *>(str.data()), str.size(), rxp_opt, &errc, &err_off, nullptr); |
| 44 | if (nullptr == result) { |
| 45 | PCRE2_UCHAR err_buff[128]; |
| 46 | auto err_size = pcre2_get_error_message(errc, err_buff, sizeof(err_buff)); |
| 47 | return Errata(S_ERROR, R"(Failed to parse regular expression - error "{}" [{}] at offset {} in "{}".)", |
| 48 | TextView(reinterpret_cast<char const *>(err_buff), err_size), errc, err_off, str); |
| 49 | } |
| 50 | return {result}; |
| 51 | }; |
| 52 | |
| 53 | int |
| 54 | Rxp::operator()(swoc::TextView text, pcre2_match_data *match) const |
no test coverage detected