| 335 | // and may not be NUL-terminated. |
| 336 | template <typename CharType> |
| 337 | GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ |
| 338 | GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ |
| 339 | GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ static CharFormat |
| 340 | PrintCharsAsStringTo(const CharType* begin, size_t len, ostream* os) { |
| 341 | const char* const quote_prefix = GetCharWidthPrefix(*begin); |
| 342 | *os << quote_prefix << "\""; |
| 343 | bool is_previous_hex = false; |
| 344 | CharFormat print_format = kAsIs; |
| 345 | for (size_t index = 0; index < len; ++index) { |
| 346 | const CharType cur = begin[index]; |
| 347 | if (is_previous_hex && IsXDigit(cur)) { |
| 348 | // Previous character is of '\x..' form and this character can be |
| 349 | // interpreted as another hexadecimal digit in its number. Break string to |
| 350 | // disambiguate. |
| 351 | *os << "\" " << quote_prefix << "\""; |
| 352 | } |
| 353 | is_previous_hex = PrintAsStringLiteralTo(cur, os) == kHexEscape; |
| 354 | // Remember if any characters required hex escaping. |
| 355 | if (is_previous_hex) { |
| 356 | print_format = kHexEscape; |
| 357 | } |
| 358 | } |
| 359 | *os << "\""; |
| 360 | return print_format; |
| 361 | } |
| 362 | |
| 363 | // Prints a (const) char/wchar_t array of 'len' elements, starting at address |
| 364 | // 'begin'. CharType must be either char or wchar_t. |
no test coverage detected