summaryrefslogtreecommitdiff
path: root/usr.bin/join/join.c
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2003-12-28 19:53:24 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2003-12-28 19:53:24 +0000
commitf75db548a29591de5bebc83b27a6aa703451fcc1 (patch)
tree41d5ba92fb192b9704d6665837af826e9d20c5a8 /usr.bin/join/join.c
parentfe25fe5c400ba7c523d11981cf8af568973ab562 (diff)
Follow Posix when writing non-matching lines. Historically, join(1)
did not change the order of fields of non-matching lines if no -o option was used, but -a or -v was specified. This update writes the join field first, followed by the remaining fields of a non-matching line. This change breaks the old security(8), so don't forget to update /etc/security. From PR 2208. Testing and man page help and ok by jmc@ ok millert@ deraadt@
Diffstat (limited to 'usr.bin/join/join.c')
-rw-r--r--usr.bin/join/join.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/usr.bin/join/join.c b/usr.bin/join/join.c
index 6711d149da3..9bcd91a0049 100644
--- a/usr.bin/join/join.c
+++ b/usr.bin/join/join.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: join.c,v 1.17 2003/12/12 10:38:44 otto Exp $ */
+/* $OpenBSD: join.c,v 1.18 2003/12/28 19:53:23 otto Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -41,7 +41,7 @@ static const char copyright[] =
#ifndef lint
/*static char sccsid[] = "@(#)join.c 8.6 (Berkeley) 5/4/95"; */
-static const char rcsid[] = "$OpenBSD: join.c,v 1.17 2003/12/12 10:38:44 otto Exp $";
+static const char rcsid[] = "$OpenBSD: join.c,v 1.18 2003/12/28 19:53:23 otto Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -449,9 +449,16 @@ outoneline(INPUT *F, LINE *lp)
else
outfield(lp, 0, 1);
}
- else
+ else {
+ /*
+ * Output the join field, then the remaining fields from F
+ */
+ outfield(lp, F->joinf, 0);
for (cnt = 0; cnt < lp->fieldcnt; ++cnt)
- outfield(lp, cnt, 0);
+ if (F->joinf != cnt)
+ outfield(lp, cnt, 0);
+ }
+
putchar('\n');
if (ferror(stdout))
err(1, "stdout");