diff options
author | peter <peter@FreeBSD.org> | 1997-03-11 13:08:12 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1997-03-11 13:08:12 +0000 |
commit | 297505f8fa9ec32b558f82504c27404854c3e313 (patch) | |
tree | 5902089a1ad90a715cb57bccc9fcdee6a33122e7 /usr.bin/join | |
parent | cc62aa07770cbb99fb48c7068048a9fbd9326313 (diff) | |
download | FreeBSD-src-297505f8fa9ec32b558f82504c27404854c3e313.zip FreeBSD-src-297505f8fa9ec32b558f82504c27404854c3e313.tar.gz |
Import some parts of CSRG 4.4BSD-Lite2 usr.bin sources to fix tree build.
Diffstat (limited to 'usr.bin/join')
-rw-r--r-- | usr.bin/join/join.1 | 13 | ||||
-rw-r--r-- | usr.bin/join/join.c | 17 |
2 files changed, 22 insertions, 8 deletions
diff --git a/usr.bin/join/join.1 b/usr.bin/join/join.1 index fa383c6..a1855cf 100644 --- a/usr.bin/join/join.1 +++ b/usr.bin/join/join.1 @@ -32,9 +32,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)join.1 8.1 (Berkeley) 6/6/93 +.\" @(#)join.1 8.3 (Berkeley) 4/28/95 .\" -.Dd June 6, 1993 +.Dd April 28, 1995 .Dt JOIN 1 .Os .Sh NAME @@ -84,6 +84,11 @@ The following options are available: In addition to the default output, produce a line for each unpairable line in file .Ar file_number . +(The argument to +.Fl a +must not be preceded by a space; see the +.Sx COMPATIBILITY +section.) .It Fl e Ar string Replace empty output fields with .Ar string . @@ -165,6 +170,10 @@ the following options are available: .It Fl a In addition to the default output, produce a line for each unpairable line in both file 1 and file 2. +(To distinguish between this and +.Fl a Ar file_number , +.Nm join +currently requires that the latter not include any white space.) .It Fl j1 Ar field Join on the .Ar field Ns 'th diff --git a/usr.bin/join/join.c b/usr.bin/join/join.c index 587fa84..122c62f 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]; } /* @@ -309,7 +314,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); @@ -351,9 +356,9 @@ cmp(lp1, fieldno1, lp2, fieldno2) LINE *lp1, *lp2; u_long fieldno1, fieldno2; { - if (lp1->fieldcnt < fieldno1) - return (lp2->fieldcnt < fieldno2 ? 0 : 1); - if (lp2->fieldcnt < fieldno2) + if (lp1->fieldcnt <= fieldno1) + return (lp2->fieldcnt <= fieldno2 ? 0 : 1); + if (lp2->fieldcnt <= fieldno2) return (-1); return (strcmp(lp1->fields[fieldno1], lp2->fields[fieldno2])); } @@ -472,7 +477,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] != '.') |