Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Ryzen CPU and AMD GPU vendor string and break on first regex match #250

Merged
merged 2 commits into from
Oct 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/Views/HardwareView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public class About.HardwareView : Gtk.Grid {
} else if (cpu.@value == 6) {
result += _("Hexa-Core %s").printf (clean_name (cpu.key));
} else {
result += "%u\u00D7 %s ".printf (cpu.@value, clean_name (cpu.key));
result += "%u \u00D7 %s ".printf (cpu.@value, clean_name (cpu.key));
}
}

Expand Down Expand Up @@ -410,23 +410,30 @@ public class About.HardwareView : Gtk.Grid {

string pretty = GLib.Markup.escape_text (info).strip ();

const GraphicsReplaceStrings REPLACE_STRINGS[] = {
const ReplaceStrings REPLACE_STRINGS[] = {
{ "Mesa DRI ", ""},
{ "Mesa (.*)", "\\1"},
{ "[(]R[)]", "®"},
{ "[(]TM[)]", "™"},
{ "Gallium .* on (AMD .*)", "\\1"},
{ "(AMD .*) [(].*", "\\1"},
{ "(AMD Ryzen) (.*)", "\\1 \\2"},
{ "(AMD [A-Z])(.*)", "\\1\\L\\2\\E"},
{ "Advanced Micro Devices, Inc\\. \\[.*?\\] .*? \\[(.*?)\\] .*", "AMD® \\1"},
{ "Advanced Micro Devices, Inc\\. \\[.*?\\] (.*)", "AMD® \\1"},
{ "Graphics Controller", "Graphics"},
{ "Intel Corporation", "Intel®"},
{ "NVIDIA Corporation (.*) \\[(\\S*) (\\S*) (.*)\\]", "NVIDIA® \\2® \\3® \\4"}
};

try {
foreach (GraphicsReplaceStrings replace_string in REPLACE_STRINGS) {
foreach (ReplaceStrings replace_string in REPLACE_STRINGS) {
GLib.Regex re = new GLib.Regex (replace_string.regex, 0, 0);
bool matched = re.match (pretty);
pretty = re.replace (pretty, -1, 0, replace_string.replacement, 0);
if (matched) {
break;
}
}
} catch (Error e) {
critical ("Couldn't cleanup vendor string: %s", e.message);
Expand Down Expand Up @@ -501,7 +508,7 @@ public class About.HardwareView : Gtk.Grid {
return disk_name;
}

struct GraphicsReplaceStrings {
struct ReplaceStrings {
string regex;
string replacement;
}
Expand Down