MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / CheckRE2

Function CheckRE2

internal/re2_options.h:30–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28}
29
30inline absl::Status CheckRE2(const RE2& re, int max_program_size) {
31 if (!re.ok()) {
32 switch (re.error_code()) {
33 case RE2::ErrorInternal:
34 return absl::InternalError(
35 absl::StrCat("internal RE2 error: ", re.error()));
36 case RE2::ErrorPatternTooLarge:
37 return absl::InvalidArgumentError(
38 absl::StrCat("regular expression too large: ", re.error()));
39 default:
40 return absl::InvalidArgumentError(
41 absl::StrCat("invalid regular expression: ", re.error()));
42 }
43 }
44 int program_size = re.ProgramSize();
45 if (max_program_size > 0 && program_size > 0 &&
46 program_size > max_program_size) {
47 return absl::InvalidArgumentError(
48 "regular expression exceeds max allowed size");
49 }
50 int reverse_program_size = re.ReverseProgramSize();
51 if (max_program_size > 0 && reverse_program_size > 0 &&
52 reverse_program_size > max_program_size) {
53 return absl::InvalidArgumentError(
54 "regular expression exceeds max allowed size");
55 }
56 return absl::OkStatus();
57}
58
59} // namespace cel::internal
60

Callers 9

BuildRegexProgramMethod · 0.85
ExtractStringFunction · 0.85
CaptureStringFunction · 0.85
CaptureStringNFunction · 0.85
ExtractFunction · 0.85
ExtractAllFunction · 0.85
ReplaceAllFunction · 0.85
ReplaceNFunction · 0.85
RegisterRegexFunctionsFunction · 0.85

Calls 2

error_codeMethod · 0.80
okMethod · 0.45

Tested by

no test coverage detected