summaryrefslogtreecommitdiffstats
path: root/usr.bin/uniq
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2002-06-21 07:59:31 +0000
committertjr <tjr@FreeBSD.org>2002-06-21 07:59:31 +0000
commit37c7624aa90797b441184b242ab75bb86b617d00 (patch)
treecac0739f7e649309c9cb96310fcd41ef7827eae7 /usr.bin/uniq
parent3c39d328716b3f1751e747e118b513c2433018c0 (diff)
downloadFreeBSD-src-37c7624aa90797b441184b242ab75bb86b617d00.zip
FreeBSD-src-37c7624aa90797b441184b242ab75bb86b617d00.tar.gz
Skip fields in the manner required by POSIX, and the way V7 did it.
MFC after: 1 week
Diffstat (limited to 'usr.bin/uniq')
-rw-r--r--usr.bin/uniq/uniq.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/usr.bin/uniq/uniq.c b/usr.bin/uniq/uniq.c
index 85733f0..c8bb5d4 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);
}
OpenPOWER on IntegriCloud