| 11368 | GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ |
| 11369 | GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ |
| 11370 | static CharFormat PrintCharsAsStringTo( |
| 11371 | const CharType* begin, size_t len, ostream* os) { |
| 11372 | const char* const kQuoteBegin = sizeof(CharType) == 1 ? "\"" : "L\""; |
| 11373 | *os << kQuoteBegin; |
| 11374 | bool is_previous_hex = false; |
| 11375 | CharFormat print_format = kAsIs; |
| 11376 | for (size_t index = 0; index < len; ++index) { |
| 11377 | const CharType cur = begin[index]; |
| 11378 | if (is_previous_hex && IsXDigit(cur)) { |
| 11379 | // Previous character is of '\x..' form and this character can be |
| 11380 | // interpreted as another hexadecimal digit in its number. Break string to |
| 11381 | // disambiguate. |
| 11382 | *os << "\" " << kQuoteBegin; |
| 11383 | } |
| 11384 | is_previous_hex = PrintAsStringLiteralTo(cur, os) == kHexEscape; |
| 11385 | // Remember if any characters required hex escaping. |
| 11386 | if (is_previous_hex) { |
| 11387 | print_format = kHexEscape; |
| 11388 | } |
| 11389 | } |
| 11390 | *os << "\""; |
| 11391 | return print_format; |
| 11392 | } |
| 11393 | |
| 11394 | // Prints a (const) char/wchar_t array of 'len' elements, starting at address |
| 11395 | // 'begin'. CharType must be either char or wchar_t. |
no test coverage detected