Returns true iff the given atom (specified by escaped and pattern) matches ch. The result is undefined if the atom is invalid.
| 10496 | // Returns true iff the given atom (specified by escaped and pattern) |
| 10497 | // matches ch. The result is undefined if the atom is invalid. |
| 10498 | bool AtomMatchesChar(bool escaped, char pattern_char, char ch) { |
| 10499 | if (escaped) { // "\\p" where p is pattern_char. |
| 10500 | switch (pattern_char) { |
| 10501 | case 'd': return IsAsciiDigit(ch); |
| 10502 | case 'D': return !IsAsciiDigit(ch); |
| 10503 | case 'f': return ch == '\f'; |
| 10504 | case 'n': return ch == '\n'; |
| 10505 | case 'r': return ch == '\r'; |
| 10506 | case 's': return IsAsciiWhiteSpace(ch); |
| 10507 | case 'S': return !IsAsciiWhiteSpace(ch); |
| 10508 | case 't': return ch == '\t'; |
| 10509 | case 'v': return ch == '\v'; |
| 10510 | case 'w': return IsAsciiWordChar(ch); |
| 10511 | case 'W': return !IsAsciiWordChar(ch); |
| 10512 | } |
| 10513 | return IsAsciiPunct(pattern_char) && pattern_char == ch; |
| 10514 | } |
| 10515 | |
| 10516 | return (pattern_char == '.' && ch != '\n') || pattern_char == ch; |
| 10517 | } |
| 10518 | |
| 10519 | // Helper function used by ValidateRegex() to format error messages. |
| 10520 | static std::string FormatRegexSyntaxError(const char* regex, int index) { |
no test coverage detected