| 19 | namespace strings { |
| 20 | |
| 21 | void Scanner::ScanUntilImpl(char end_ch, bool escaped) { |
| 22 | for (;;) { |
| 23 | if (cur_.empty()) { |
| 24 | Error(); |
| 25 | return; |
| 26 | } |
| 27 | const char ch = cur_[0]; |
| 28 | if (ch == end_ch) { |
| 29 | return; |
| 30 | } |
| 31 | |
| 32 | cur_.remove_prefix(1); |
| 33 | if (escaped && ch == '\\') { |
| 34 | // Escape character, skip next character. |
| 35 | if (cur_.empty()) { |
| 36 | Error(); |
| 37 | return; |
| 38 | } |
| 39 | cur_.remove_prefix(1); |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | bool Scanner::GetResult(StringPiece* remaining, StringPiece* capture) { |
| 45 | if (error_) { |