summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/unix.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/unix.c b/src/unix.c
index 181ff7a..b9e652d 100644
--- a/src/unix.c
+++ b/src/unix.c
@@ -75,6 +75,7 @@ static int _query(struct nm_spool *s, enum nm_query query, struct nm_status *sta
while (!feof(f)) {
static char ln[128];
+ char *eol;
if (!fgets(ln, sizeof(ln), f))
break;
@@ -88,7 +89,15 @@ static int _query(struct nm_spool *s, enum nm_query query, struct nm_status *sta
old++;
hdr = 0;
}
- }
+
+ /* Position the cursor at the next newline */
+ do {
+ if (eol = strchr(ln, '\n')) {
+ fseek(f, -1 * strlen(eol + 1), SEEK_CUR);
+ break;
+ }
+ } while(fgets(ln, sizeof(ln), f));
+ }
fclose(f);