Skip to content

Commit

Permalink
Keep second 0 in firmware strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Megamouse committed Apr 18, 2023
1 parent 1f19804 commit abb85ad
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions rpcs3/util/sysinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,14 +414,21 @@ 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');
const usz dot_pos = version.find_first_of('.');
usz trim_end = version.find_last_not_of('0');

if (trim_start == umax)
if (trim_start == umax || 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')
if (end > trim_end && trim_end > dot_pos && (trim_end - dot_pos) == 1)
{
trim_end++;
}

return std::string(version.substr(trim_start, trim_end));
}
Expand Down

0 comments on commit abb85ad

Please sign in to comment.