aboutsummaryrefslogtreecommitdiff
path: root/hardinfo2
diff options
context:
space:
mode:
authorLeandro Pereira <leandro@hardinfo.org>2009-04-19 10:01:20 -0300
committerLeandro Pereira <leandro@hardinfo.org>2009-04-19 10:01:20 -0300
commitab149c6b07e5e183a0ad4dec6c886f06df6d2efc (patch)
treeab903683a7f83193de945cff42d9a9a1f00df07c /hardinfo2
parentb8ec48cc434da4c35e574cdd8d9c7465f101799c (diff)
Clean up CPU description on benchmark display
Diffstat (limited to 'hardinfo2')
-rw-r--r--hardinfo2/arch/common/printers.h2
-rw-r--r--hardinfo2/arch/linux/common/filesystem.h2
-rw-r--r--hardinfo2/arch/linux/common/resources.h4
-rw-r--r--hardinfo2/arch/linux/common/storage.h2
-rw-r--r--hardinfo2/benchmark.c34
-rw-r--r--hardinfo2/hardinfo.h3
-rw-r--r--hardinfo2/shell.c2
-rw-r--r--hardinfo2/util.c13
8 files changed, 51 insertions, 11 deletions
diff --git a/hardinfo2/arch/common/printers.h b/hardinfo2/arch/common/printers.h
index 2f221252..75b6e84a 100644
--- a/hardinfo2/arch/common/printers.h
+++ b/hardinfo2/arch/common/printers.h
@@ -234,7 +234,7 @@ __scan_printers(void)
} else {
if (temp) {
/* FIXME Do proper escaping */
- temp = g_strdup(strreplace(temp, "&=", ' '));
+ temp = g_strdup(strreplacechr(temp, "&=", ' '));
} else {
temp = g_strdup("Unknown");
}
diff --git a/hardinfo2/arch/linux/common/filesystem.h b/hardinfo2/arch/linux/common/filesystem.h
index 1eff0818..48cbbd51 100644
--- a/hardinfo2/arch/linux/common/filesystem.h
+++ b/hardinfo2/arch/linux/common/filesystem.h
@@ -77,7 +77,7 @@ scan_filesystems(void)
g_free(strhash);
}
- strreplace(tmp[0], "#", '_');
+ strreplacechr(tmp[0], "#", '_');
strhash = g_strdup_printf("[%s]\n"
"Filesystem=%s\n"
diff --git a/hardinfo2/arch/linux/common/resources.h b/hardinfo2/arch/linux/common/resources.h
index 20db65e9..acfbe377 100644
--- a/hardinfo2/arch/linux/common/resources.h
+++ b/hardinfo2/arch/linux/common/resources.h
@@ -38,12 +38,12 @@ static gchar *_resource_obtain_name(gchar *name)
if (g_regex_match(_regex_pci, name, 0, NULL)) {
temp = module_call_method_param("devices::getPCIDeviceDescription", name);
if (temp) {
- return temp;
+ return g_strdup_printf("<b><small>PCI</small></b> %s", (gchar *)idle_free(temp));
}
} else if (g_regex_match(_regex_module, name, 0, NULL)) {
temp = module_call_method_param("computer::getKernelModuleDescription", name);
if (temp) {
- return temp;
+ return g_strdup_printf("<b><small>Module</small></b> %s", (gchar *)idle_free(temp));
}
}
diff --git a/hardinfo2/arch/linux/common/storage.h b/hardinfo2/arch/linux/common/storage.h
index 06593a09..7caf1d96 100644
--- a/hardinfo2/arch/linux/common/storage.h
+++ b/hardinfo2/arch/linux/common/storage.h
@@ -239,7 +239,7 @@ __scan_ide_devices(void)
}
} else if ((strstr(buf, "read") || strstr(buf, "write")) && strstr(buf, "kB/s")) {
speed = g_strconcat(speed ? speed : "",
- strreplace(g_strstrip(buf), ":", '='),
+ strreplacechr(g_strstrip(buf), ":", '='),
"\n", NULL);
} else if (strstr(buf, "Device seems to be")) {
driver = g_strdup_printf("Driver=%s\n", strchr(buf, ':') + 1);
diff --git a/hardinfo2/benchmark.c b/hardinfo2/benchmark.c
index 97796b37..7189a37e 100644
--- a/hardinfo2/benchmark.c
+++ b/hardinfo2/benchmark.c
@@ -155,6 +155,32 @@ gdouble benchmark_parallel_for(guint start, guint end,
return elapsed_time;
}
+static gchar *clean_cpuname(gchar *cpuname)
+{
+ gchar *ret = NULL, *tmp;
+ gchar *remove[] = {
+ "(R)", "(r)", "(TM)", "(tm)", "Processor",
+ "Technology", "processor", "CPU",
+ NULL
+ };
+ gint i;
+
+ ret = g_strdup(cpuname);
+ for (i = 0; remove[i]; i++) {
+ tmp = strreplace(ret, remove[i], "");
+ g_free(ret);
+ ret = tmp;
+ }
+
+ ret = strend(ret, '@');
+ ret = g_strstrip(ret);
+
+ tmp = g_strdup(ret);
+ g_free(ret);
+
+ return tmp;
+}
+
static gchar *__benchmark_include_results(gdouble result,
const gchar * benchmark,
ShellOrderType order_type)
@@ -177,12 +203,14 @@ static gchar *__benchmark_include_results(gdouble result,
machines = g_key_file_get_keys(conf, benchmark, NULL, NULL);
for (i = 0; machines && machines[i]; i++) {
- gchar *value;
+ gchar *value, *cleaned_machine;
value = g_key_file_get_value(conf, benchmark, machines[i], NULL);
- results = g_strconcat(results, machines[i], "=", value, "\n", NULL);
-
+ cleaned_machine = clean_cpuname(machines[i]);
+ results = h_strconcat(results, cleaned_machine, "=", value, "\n", NULL);
+
g_free(value);
+ g_free(cleaned_machine);
}
g_strfreev(machines);
diff --git a/hardinfo2/hardinfo.h b/hardinfo2/hardinfo.h
index 6ac25bec..2fe955fe 100644
--- a/hardinfo2/hardinfo.h
+++ b/hardinfo2/hardinfo.h
@@ -68,7 +68,8 @@ struct _ModuleAbout {
inline void remove_quotes(gchar *str);
inline char *strend(gchar *str, gchar chr);
inline void remove_linefeed(gchar *str);
-gchar *strreplace(gchar *string, gchar *replace, gchar new_char);
+gchar *strreplacechr(gchar *string, gchar *replace, gchar new_char);
+gchar *strreplace(gchar *string, gchar *replace, gchar *replacement);
/* Widget utility functions */
void widget_set_cursor(GtkWidget *widget, GdkCursorType cursor_type);
diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c
index 2fb36010..c33be0ef 100644
--- a/hardinfo2/shell.c
+++ b/hardinfo2/shell.c
@@ -1074,7 +1074,7 @@ static void update_progress()
tmp = g_strdup_printf("%.2f", floatval);
}
- tmp = strreplace(tmp, ",", '.');
+ tmp = strreplacechr(tmp, ",", '.');
gtk_tree_store_set(store, &iter, INFO_TREE_COL_PROGRESS, cur,
INFO_TREE_COL_VALUE, tmp, -1);
g_free(tmp);
diff --git a/hardinfo2/util.c b/hardinfo2/util.c
index ac2ad3b5..dd89e199 100644
--- a/hardinfo2/util.c
+++ b/hardinfo2/util.c
@@ -493,7 +493,7 @@ void open_url(gchar * url)
}
/* Copyright: Jens Låås, SLU 2002 */
-gchar *strreplace(gchar * string, gchar * replace, gchar new_char)
+gchar *strreplacechr(gchar * string, gchar * replace, gchar new_char)
{
gchar *s;
for (s = string; *s; s++)
@@ -503,6 +503,17 @@ gchar *strreplace(gchar * string, gchar * replace, gchar new_char)
return string;
}
+gchar *strreplace(gchar *string, gchar *replace, gchar *replacement)
+{
+ gchar **tmp, *ret;
+
+ tmp = g_strsplit(string, replace, 0);
+ ret = g_strjoinv(replacement, tmp);
+ g_strfreev(tmp);
+
+ return ret;
+}
+
static GHashTable *__module_methods = NULL;
static void module_register_methods(ShellModule * module)