From 2e0b5751ce80491a5ea943a23dfecd4aa8ab7a1f Mon Sep 17 00:00:00 2001 From: Tbusk Date: Fri, 14 Nov 2025 17:25:17 -0500 Subject: [PATCH 1/2] patch: csv parsing --- src/Resources/CPU.vala | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Resources/CPU.vala b/src/Resources/CPU.vala index bf3524f58..79992ca1c 100644 --- a/src/Resources/CPU.vala +++ b/src/Resources/CPU.vala @@ -213,8 +213,18 @@ public class Monitor.CPU : Object { dis = new DataInputStream (csv_file.read ()); string flag_data; while ((flag_data = dis.read_line ()) != null) { - var splitted = flag_data.split (","); - all_flags.set (splitted[0], splitted[1].replace ("\r", "")); + + int comma_position = flag_data.index_of_char (','); + + if (comma_position == -1) break; // quick exit if no commas are in the line + + string key = flag_data.substring (0, comma_position); + string value = flag_data.substring (comma_position + 1) + .replace ("\"", "") + .replace (" ", " ") + .strip (); + + all_flags.set (key, value.replace ("\r", "")); } debug ("Parsed file %s", csv_file.get_path ()); From 8b3cb9fdac82d9633808f5ccd554bb6043c93db2 Mon Sep 17 00:00:00 2001 From: Tbusk Date: Fri, 14 Nov 2025 17:38:06 -0500 Subject: [PATCH 2/2] patch: linting error in CPU.vala --- src/Resources/CPU.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Resources/CPU.vala b/src/Resources/CPU.vala index 79992ca1c..4e411052a 100644 --- a/src/Resources/CPU.vala +++ b/src/Resources/CPU.vala @@ -215,7 +215,7 @@ public class Monitor.CPU : Object { while ((flag_data = dis.read_line ()) != null) { int comma_position = flag_data.index_of_char (','); - + if (comma_position == -1) break; // quick exit if no commas are in the line string key = flag_data.substring (0, comma_position); @@ -223,7 +223,7 @@ public class Monitor.CPU : Object { .replace ("\"", "") .replace (" ", " ") .strip (); - + all_flags.set (key, value.replace ("\r", "")); } debug ("Parsed file %s", csv_file.get_path ());