| 224 | |
| 225 | public: |
| 226 | rxscope(const bool u, const bool i, const char *pattern, int len) : scope_t(u) |
| 227 | { |
| 228 | int flags = REG_NOSUB | REG_EXTENDED | (i ? REG_ICASE : 0); |
| 229 | char *str = TSstrndup(pattern, len); |
| 230 | int error = regcomp(&rx, str, flags); |
| 231 | if (error) { |
| 232 | TSError("stream-editor: can't compile regexp [%s]", str); |
| 233 | TSfree(str); |
| 234 | throw std::runtime_error("stream editor: Error compiling regex, regcomp in rxscope"); |
| 235 | } |
| 236 | TSfree(str); |
| 237 | } |
| 238 | |
| 239 | ~rxscope() override { regfree(&rx); } |
| 240 | }; |