From d5eebd6ab4903ca085ce47bcc909655620c9c7a5 Mon Sep 17 00:00:00 2001 From: Eladash Date: Tue, 6 Jun 2023 09:11:32 +0300 Subject: [PATCH] debugger: Fix trailing spaces in PPU register dump --- Utilities/StrFmt.cpp | 8 +++++++- Utilities/StrUtil.h | 3 ++- rpcs3/Emu/Cell/PPUThread.cpp | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Utilities/StrFmt.cpp b/Utilities/StrFmt.cpp index 07e8bd43a7..1a675fa35e 100644 --- a/Utilities/StrFmt.cpp +++ b/Utilities/StrFmt.cpp @@ -589,7 +589,7 @@ std::vector fmt::split(std::string_view source, std::initializer_li return result; } -std::string fmt::trim(const std::string& source, const std::string& values) +std::string fmt::trim(const std::string& source, std::string_view values) { usz begin = source.find_first_not_of(values); @@ -599,6 +599,12 @@ std::string fmt::trim(const std::string& source, const std::string& values) return source.substr(begin, source.find_last_not_of(values) + 1); } +void fmt::trim_back(std::string& source, std::string_view values) +{ + const usz index = source.find_last_not_of(values); + source.resize(index + 1); +} + std::string fmt::to_upper(std::string_view string) { std::string result; diff --git a/Utilities/StrUtil.h b/Utilities/StrUtil.h index ad5a9cfb32..74df4eae07 100644 --- a/Utilities/StrUtil.h +++ b/Utilities/StrUtil.h @@ -124,7 +124,8 @@ namespace fmt } std::vector split(std::string_view source, std::initializer_list separators, bool is_skip_empty = true); - std::string trim(const std::string& source, const std::string& values = " \t"); + std::string trim(const std::string& source, std::string_view values = " \t"); + void trim_back(std::string& source, std::string_view values = " \t"); template std::string merge(const T& source, const std::string& separator) diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 94f76ca56e..3ff8664085 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -1153,7 +1153,8 @@ void ppu_thread::dump_regs(std::string& ret) const } } - fmt::append(ret, "\n"); + fmt::trim_back(ret); + ret += '\n'; } for (uint i = 0; i < 32; ++i)