Returns true iff the given atom (specified by escaped and pattern) matches ch. The result is undefined if the atom is invalid.
| 8002 | // Returns true iff the given atom (specified by escaped and pattern) |
| 8003 | // matches ch. The result is undefined if the atom is invalid. |
| 8004 | bool AtomMatchesChar(bool escaped, char pattern_char, char ch) { |
| 8005 | if (escaped) { // "\\p" where p is pattern_char. |
| 8006 | switch (pattern_char) { |
| 8007 | case 'd': return IsAsciiDigit(ch); |
| 8008 | case 'D': return !IsAsciiDigit(ch); |
| 8009 | case 'f': return ch == '\f'; |
| 8010 | case 'n': return ch == '\n'; |
| 8011 | case 'r': return ch == '\r'; |
| 8012 | case 's': return IsAsciiWhiteSpace(ch); |
| 8013 | case 'S': return !IsAsciiWhiteSpace(ch); |
| 8014 | case 't': return ch == '\t'; |
| 8015 | case 'v': return ch == '\v'; |
| 8016 | case 'w': return IsAsciiWordChar(ch); |
| 8017 | case 'W': return !IsAsciiWordChar(ch); |
| 8018 | } |
| 8019 | return IsAsciiPunct(pattern_char) && pattern_char == ch; |
| 8020 | } |
| 8021 | |
| 8022 | return (pattern_char == '.' && ch != '\n') || pattern_char == ch; |
| 8023 | } |
| 8024 | |
| 8025 | // Helper function used by ValidateRegex() to format error messages. |
| 8026 | String FormatRegexSyntaxError(const char* regex, int index) { |
no test coverage detected