From a701fc7aa6d38d27ea9909d6200fafa3a4ffbd6e Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Fri, 27 Nov 1998 10:34:01 +0000 Subject: [PATCH] Minor /proc/net/dev parsing updates; has nothing to do with latest compilation problems. --- sysdeps/linux/netload.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sysdeps/linux/netload.c b/sysdeps/linux/netload.c index 15b7446e..4fa1b39e 100644 --- a/sysdeps/linux/netload.c +++ b/sysdeps/linux/netload.c @@ -258,13 +258,13 @@ glibtop_get_netload_s (glibtop *server, glibtop_netload *buf, fields = 0; while (*p != '|') { - if (isspace (*p)) - fields++; - p++; + if (!isspace (*p++)) continue; + while (isspace (*p++)) ; + fields++; } /* Should never happen. */ - if (!fields) return; + if (fields < 2) return; fields--; while (fgets (buffer, BUFSIZ-1, f)) { @@ -287,8 +287,10 @@ glibtop_get_netload_s (glibtop *server, glibtop_netload *buf, /* Only read byte counts if we really have them. */ - if (have_bytes) + if (have_bytes) { buf->bytes_in = strtoul (p, &p, 0); + fields--; + } buf->packets_in = strtoul (p, &p, 0); buf->errors_in = strtoul (p, &p, 0);