MCPcopy Create free account
hub / github.com/apache/trafficserver / Contains

Method Contains

src/cripts/Matcher.cc:69–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67}
68
69Matcher::PCRE::Result
70Matcher::PCRE::Contains(cripts::string_view subject, PCRE2_SIZE offset, uint32_t options)
71{
72 Matcher::PCRE::Result res(subject);
73 pcre2_general_context *ctx =
74 pcre2_general_context_create(&Matcher::PCRE::Result::malloc, [](void *, void *) -> void {}, static_cast<void *>(&res));
75
76 for (auto &it : _regexes) {
77 auto &[_, re] = it;
78 res._data = pcre2_match_data_create_from_pattern(re, ctx);
79 int ret = pcre2_match(re, reinterpret_cast<PCRE2_SPTR>(subject.data()), subject.length(), offset, options, res._data, nullptr);
80
81 if (ret >= 0) {
82 res._ovector = pcre2_get_ovector_pointer(res._data);
83 res._match = &it - &_regexes[0] + 1; // This is slightly odd, but it's one more than the zero-based indexes.
84 break;
85 }
86 }
87
88 return res;
89}
90
91} // namespace cripts

Callers

nothing calls this directly

Calls 2

dataMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected