diff options
| author | Peter Wemm <peter@FreeBSD.org> | 1997-03-11 13:45:59 +0000 |
|---|---|---|
| committer | Peter Wemm <peter@FreeBSD.org> | 1997-03-11 13:45:59 +0000 |
| commit | 6f0a860fc1e58338349173799291c963808faee9 (patch) | |
| tree | b9e210930d3f402b12f27e8629d4b462439d5b4d /usr.bin/join | |
| parent | df3f5d9dd51fa82a604ec559a75d3791a7b80ed5 (diff) | |
Notes
Diffstat (limited to 'usr.bin/join')
| -rw-r--r-- | usr.bin/join/join.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/usr.bin/join/join.c b/usr.bin/join/join.c index a3efd7e2a2c3..bc1f07430661 100644 --- a/usr.bin/join/join.c +++ b/usr.bin/join/join.c @@ -42,7 +42,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)join.c 8.3 (Berkeley) 4/16/94"; +static char sccsid[] = "@(#)join.c 8.6 (Berkeley) 5/4/95"; #endif /* not lint */ #include <sys/param.h> @@ -53,6 +53,7 @@ static char sccsid[] = "@(#)join.c 8.3 (Berkeley) 4/16/94"; #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> /* * There's a structure per input file which encapsulates the state of the @@ -288,6 +289,10 @@ slurp(F) F->setalloc * sizeof(LINE))) == NULL) err(1, NULL); memset(F->set + cnt, 0, 50 * sizeof(LINE)); + + /* re-set lastlp in case it moved */ + if (lastlp != NULL) + lastlp = &F->set[F->setcnt - 1]; } /* @@ -310,7 +315,7 @@ slurp(F) if ((bp = fgetln(F->fp, &len)) == NULL) return; if (lp->linealloc <= len + 1) { - lp->linealloc += MAX(100, len + 1); + lp->linealloc += MAX(100, len + 1 - lp->linealloc); if ((lp->line = realloc(lp->line, lp->linealloc)) == NULL) err(1, NULL); @@ -353,7 +358,7 @@ cmp(lp1, fieldno1, lp2, fieldno2) u_long fieldno1, fieldno2; { if (lp1->fieldcnt <= fieldno1) - return (lp2->fieldcnt < fieldno2 ? 0 : 1); + return (lp2->fieldcnt <= fieldno2 ? 0 : 1); if (lp2->fieldcnt <= fieldno2) return (-1); return (strcmp(lp1->fields[fieldno1], lp2->fields[fieldno2])); @@ -473,7 +478,7 @@ fieldarg(option) u_long fieldno; char *end, *token; - while ((token = strsep(&option, " \t")) != NULL) { + while ((token = strsep(&option, ", \t")) != NULL) { if (*token == '\0') continue; if (token[0] != '1' && token[0] != '2' || token[1] != '.') |
