From 5107d1b69bd50df23cd538e686b2fb139e41755e Mon Sep 17 00:00:00 2001 From: Megamouse Date: Tue, 18 Apr 2023 20:07:02 +0200 Subject: [PATCH] Keep second 0 in firmware strings --- rpcs3/util/sysinfo.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/rpcs3/util/sysinfo.cpp b/rpcs3/util/sysinfo.cpp index 8ee13a2aee..fdfa5991ec 100755 --- a/rpcs3/util/sysinfo.cpp +++ b/rpcs3/util/sysinfo.cpp @@ -414,15 +414,24 @@ std::string utils::get_firmware_version() version = version.substr(start, end - start); - // Trim version + // Trim version (e.g. '04.8900' becomes '4.89') const usz trim_start = version.find_first_not_of('0'); - const usz trim_end = version.find_last_not_of('0'); if (trim_start == umax) { return {}; } + const usz dot_pos = version.find_first_of('.', trim_start); + + if (dot_pos == umax) + { + return {}; + } + + // Try to keep the second 0 in the minor version (e.g. '04.9000' becomes '4.90' instead of '4.9') + const usz trim_end = std::max(version.find_last_not_of('0', dot_pos + 1), std::min(dot_pos + 2, version.size())); + return std::string(version.substr(trim_start, trim_end)); }