diff options
author | Tim J. Robbins <tjr@FreeBSD.org> | 2002-06-21 07:59:31 +0000 |
---|---|---|
committer | Tim J. Robbins <tjr@FreeBSD.org> | 2002-06-21 07:59:31 +0000 |
commit | 382ac430cd76bf985f194e2c489e16a397101fa3 (patch) | |
tree | cac0739f7e649309c9cb96310fcd41ef7827eae7 /usr.bin/uniq/uniq.c | |
parent | c1c9929e9f9ca2d44778f26ce4a60bdbe612bfaa (diff) | |
download | src-382ac430cd76bf985f194e2c489e16a397101fa3.tar.gz src-382ac430cd76bf985f194e2c489e16a397101fa3.zip |
Skip fields in the manner required by POSIX, and the way V7 did it.
MFC after: 1 week
Notes
Notes:
svn path=/head/; revision=98547
Diffstat (limited to 'usr.bin/uniq/uniq.c')
-rw-r--r-- | usr.bin/uniq/uniq.c | 18 |
1 files changed, 8 insertions, 10 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; - - for (nfields = numfields, infield = 0; nfields && *str; ++str) - if (isblank((unsigned char)*str)) { - if (infield) { - infield = 0; - --nfields; - } - } else if (!infield) - infield = 1; + register int nchars, nfields; + + 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); } |