The string representation of the values received in EqFailure() are already escaped. Split them on escaped '\n' boundaries. Leave all other escaped characters the same.
| 1533 | // escaped. Split them on escaped '\n' boundaries. Leave all other escaped |
| 1534 | // characters the same. |
| 1535 | std::vector<std::string> SplitEscapedString(const std::string& str) { |
| 1536 | std::vector<std::string> lines; |
| 1537 | size_t start = 0, end = str.size(); |
| 1538 | if (end > 2 && str[0] == '"' && str[end - 1] == '"') { |
| 1539 | ++start; |
| 1540 | --end; |
| 1541 | } |
| 1542 | bool escaped = false; |
| 1543 | for (size_t i = start; i + 1 < end; ++i) { |
| 1544 | if (escaped) { |
| 1545 | escaped = false; |
| 1546 | if (str[i] == 'n') { |
| 1547 | lines.push_back(str.substr(start, i - start - 1)); |
| 1548 | start = i + 1; |
| 1549 | } |
| 1550 | } else { |
| 1551 | escaped = str[i] == '\\'; |
| 1552 | } |
| 1553 | } |
| 1554 | lines.push_back(str.substr(start, end - start)); |
| 1555 | return lines; |
| 1556 | } |
| 1557 | |
| 1558 | } // namespace |
| 1559 |