From 382ac430cd76bf985f194e2c489e16a397101fa3 Mon Sep 17 00:00:00 2001 From: "Tim J. Robbins" Date: Fri, 21 Jun 2002 07:59:31 +0000 Subject: [PATCH] Skip fields in the manner required by POSIX, and the way V7 did it. MFC after: 1 week --- usr.bin/uniq/uniq.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/usr.bin/uniq/uniq.c b/usr.bin/uniq/uniq.c index 85733f08797b..c8bb5d4622e2 100644 --- a/usr.bin/uniq/uniq.c +++ b/usr.bin/uniq/uniq.c @@ -208,16 +208,14 @@ char * skip(str) register char *str; { - register int infield, nchars, nfields; + register int nchars, nfields; - for (nfields = numfields, infield = 0; nfields && *str; ++str) - if (isblank((unsigned char)*str)) { - if (infield) { - infield = 0; - --nfields; - } - } else if (!infield) - infield = 1; + for (nfields = 0; *str != '\0' && nfields++ != numfields; ) { + while (isblank((unsigned char)*str)) + str++; + while (*str != '\0' && !isblank((unsigned char)*str)) + str++; + } for (nchars = numchars; nchars-- && *str; ++str); return(str); }