Lines Matching refs:regex
1319 GTEST_API_ bool ValidateRegex(const char* regex);
1320 GTEST_API_ bool MatchRegexAtHead(const char* regex, const char* str);
1322 bool escaped, char ch, char repeat, const char* regex, const char* str);
1323 GTEST_API_ bool MatchRegexAnywhere(const char* regex, const char* str);
1513 "A colon-separated list of glob (not regex) patterns "
6502 bool DeathTest::Create(const char* statement, const RE* regex,
6505 statement, regex, file, line, test);
6537 const RE* regex() const { return regex_; }
6676 // regex: A regular expression object to be applied to
6712 const bool matched = RE::PartialMatch(error_message.c_str(), *regex());
6717 << " Expected: " << regex()->pattern() << "\n"
6939 ForkingDeathTest(const char* statement, const RE* regex);
7241 bool DefaultDeathTestFactory::Create(const char* statement, const RE* regex,
7269 *test = new WindowsDeathTest(statement, regex, file, line);
7275 *test = new ExecDeathTest(statement, regex, file, line);
7277 *test = new NoExecDeathTest(statement, regex);
7919 // regfree'ing an invalid regex might crash because the content
7920 // of the regex is undefined. Since the regex's are essentially
7947 void RE::Init(const char* regex) {
7948 pattern_ = posix::StrDup(regex);
7952 const size_t full_regex_len = strlen(regex) + 10;
7955 snprintf(full_pattern, full_regex_len, "^(%s)$", regex);
7962 // Some implementation of POSIX regex (e.g. on at least some
7964 // regex. We change it to an equivalent form "()" to be safe.
7966 const char* const partial_regex = (*regex == '\0') ? "()" : regex;
7970 << "Regular expression \"" << regex
8027 String FormatRegexSyntaxError(const char* regex, int index) {
8029 << " in simple regular expression \"" << regex << "\": ").GetString();
8032 // Generates non-fatal failures and returns false if regex is invalid;
8034 bool ValidateRegex(const char* regex) {
8035 if (regex == NULL) {
8037 // assertion failures to match where the regex is used in user
8047 for (int i = 0; regex[i]; i++) {
8048 if (regex[i] == '\\') { // An escape sequence
8050 if (regex[i] == '\0') {
8051 ADD_FAILURE() << FormatRegexSyntaxError(regex, i - 1)
8056 if (!IsValidEscape(regex[i])) {
8057 ADD_FAILURE() << FormatRegexSyntaxError(regex, i - 1)
8058 << "invalid escape sequence \"\\" << regex[i] << "\".";
8063 const char ch = regex[i];
8066 ADD_FAILURE() << FormatRegexSyntaxError(regex, i)
8069 } else if (ch == '$' && regex[i + 1] != '\0') {
8070 ADD_FAILURE() << FormatRegexSyntaxError(regex, i)
8074 ADD_FAILURE() << FormatRegexSyntaxError(regex, i)
8078 ADD_FAILURE() << FormatRegexSyntaxError(regex, i)
8090 // Matches a repeated regex atom followed by a valid simple regular
8091 // expression. The regex atom is defined as c if escaped is false,
8098 bool escaped, char c, char repeat, const char* regex,
8108 if (i >= min_count && MatchRegexAtHead(regex, str + i)) {
8121 // Returns true iff regex matches a prefix of str. regex must be a
8124 bool MatchRegexAtHead(const char* regex, const char* str) {
8125 if (*regex == '\0') // An empty regex matches a prefix of anything.
8128 // "$" only matches the end of a string. Note that regex being
8130 if (*regex == '$')
8133 // Is the first thing in regex an escape sequence?
8134 const bool escaped = *regex == '\\';
8136 ++regex;
8137 if (IsRepeat(regex[1])) {
8139 // here's an indirect recursion. It terminates as the regex gets
8142 escaped, regex[0], regex[1], regex + 2, str);
8144 // regex isn't empty, isn't "$", and doesn't start with a
8145 // repetition. We match the first atom of regex with the first
8147 return (*str != '\0') && AtomMatchesChar(escaped, *regex, *str) &&
8148 MatchRegexAtHead(regex + 1, str + 1);
8152 // Returns true iff regex matches any substring of str. regex must be
8156 // the regex length, so we won't need to worry about running out of
8158 // exponential with respect to the regex length + the string length,
8160 bool MatchRegexAnywhere(const char* regex, const char* str) {
8161 if (regex == NULL || str == NULL)
8164 if (*regex == '^')
8165 return MatchRegexAtHead(regex + 1, str);
8169 if (MatchRegexAtHead(regex, str))
8194 void RE::Init(const char* regex) {
8196 if (regex != NULL) {
8197 pattern_ = posix::StrDup(regex);
8200 is_valid_ = ValidateRegex(regex);
8202 // No need to calculate the full pattern when the regex is invalid.
8206 const size_t len = strlen(regex);
8213 if (*regex != '^')
8218 memcpy(buffer, regex, len);
8221 if (len == 0 || regex[len - 1] != '$')