From 48191c711146c94a6e1908654356f92c0f0ee441 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 24 Dec 1998 21:54:26 +0000 Subject: [PATCH] Small fix; look for the colon separating key and value. --- sysdeps/linux/sysinfo.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sysdeps/linux/sysinfo.c b/sysdeps/linux/sysinfo.c index a1b16b59..63a03b8c 100644 --- a/sysdeps/linux/sysinfo.c +++ b/sysdeps/linux/sysinfo.c @@ -47,7 +47,7 @@ init_sysinfo (glibtop *server) g_return_if_fail (f = fopen ("/proc/cpuinfo", "r")); while (fgets (buffer, BUFSIZ, f)) { - char *p, *key, *value; + char *p, *start, *key, *value; if (cpuinfo == NULL) { cpuinfo = &sysinfo.cpuinfo [sysinfo.ncpu++]; @@ -60,10 +60,14 @@ init_sysinfo (glibtop *server) sysinfo.ncpu = GLIBTOP_NCPU; } - p = skip_token (buffer); *p = '\0'; - p = skip_token (p+1)+1; + p = strchr (buffer, ':'); + if (!p) continue; + + *p = '\0'; start = p; p++; + while (isspace (*p)) p++; - p [strlen (p) ? strlen (p)-1 : 0] = '\0'; + while ((start > buffer) && isspace (*start)) + *start-- = '\0'; key = g_strdup (buffer); value = g_strdup (p);