================ @@ -403,9 +404,41 @@ bool Address::GetDescription(Stream &s, Target &target, return false; } +void Address::DumpName(Stream *strm, llvm::StringRef text, + const char *pattern) { + if (!pattern) { + strm->PutCString(text.data()); + return; + } + + llvm::Regex reg_pattern(pattern); + llvm::SmallVector<llvm::StringRef, 1> matches; + llvm::StringRef remaining = text; + std::string red_start = + lldb_private::ansi::FormatAnsiTerminalCodes("${ansi.fg.red}"); + std::string reset_color = + lldb_private::ansi::FormatAnsiTerminalCodes("${ansi.normal}"); + + size_t last_pos = 0; + while (reg_pattern.match(remaining, &matches)) { + llvm::StringRef match = matches[0]; + size_t match_start_pos = match.data() - text.data(); + size_t match_end_pos = match_start_pos + match.size(); + + strm->Write(text.data() + last_pos, match_start_pos - last_pos); + strm->PutCString(red_start.c_str()); + strm->Write(text.data() + match_start_pos, match.size()); + strm->PutCString(reset_color.c_str()); + last_pos = match_end_pos; + remaining = text.substr(last_pos); + } + if (last_pos < text.size()) + strm->PutCString(text.data() + last_pos); ---------------- DavidSpickett wrote:
Is this the same as using `remaining` ? Maybe it could be `if (remaining.size()) { stream remaining}`. https://github.com/llvm/llvm-project/pull/69422 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits