aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim J. Robbins <tjr@FreeBSD.org>2002-04-20 01:55:19 +0000
committerTim J. Robbins <tjr@FreeBSD.org>2002-04-20 01:55:19 +0000
commitfcb113145cd718429042b550bf7bd3280ddaa6d1 (patch)
tree4d44997949031b72ba29e38992a83ae306851749
parentccc5b4e6f4e2cc1a1fb4acfaa8dae6db269b3f6e (diff)
downloadsrc-fcb113145cd718429042b550bf7bd3280ddaa6d1.tar.gz
src-fcb113145cd718429042b550bf7bd3280ddaa6d1.zip
Allow space between -a and its argument. Honour locale collating order
by using strcoll() instead of strcmp(). PR: 36270 Reviewed by: mike
Notes
Notes: svn path=/head/; revision=95096
-rw-r--r--usr.bin/join/join.116
-rw-r--r--usr.bin/join/join.c12
2 files changed, 12 insertions, 16 deletions
diff --git a/usr.bin/join/join.1 b/usr.bin/join/join.1
index 10e00f0de40d..9a0084948f5b 100644
--- a/usr.bin/join/join.1
+++ b/usr.bin/join/join.1
@@ -35,7 +35,7 @@
.\" @(#)join.1 8.3 (Berkeley) 4/28/95
.\" $FreeBSD$
.\"
-.Dd April 28, 1995
+.Dd April 18, 2002
.Dt JOIN 1
.Os
.Sh NAME
@@ -91,11 +91,6 @@ 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 .
@@ -182,10 +177,6 @@ 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
-currently requires that the latter not include any white space.)
.It Fl j1 Ar field
Join on the
.Ar field Ns 'th
@@ -220,10 +211,7 @@ modification and should not be used.
The
.Nm
command conforms to
-.St -p1003.1-2001
-except for the requirement that there be no space between the
-.Fl a
-option and its argument.
+.St -p1003.1-2001 .
.Sh SEE ALSO
.Xr awk 1 ,
.Xr comm 1 ,
diff --git a/usr.bin/join/join.c b/usr.bin/join/join.c
index 84ea61b31e49..77d680126737 100644
--- a/usr.bin/join/join.c
+++ b/usr.bin/join/join.c
@@ -54,6 +54,7 @@ static const char rcsid[] =
#include <ctype.h>
#include <err.h>
#include <errno.h>
+#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -121,6 +122,8 @@ main(argc, argv)
int aflag, ch, cval, vflag;
char *end;
+ setlocale(LC_ALL, "");
+
F1 = &input1;
F2 = &input2;
@@ -365,7 +368,7 @@ cmp(lp1, fieldno1, lp2, fieldno2)
return (lp2->fieldcnt <= fieldno2 ? 0 : 1);
if (lp2->fieldcnt <= fieldno2)
return (-1);
- return (strcmp(lp1->fields[fieldno1], lp2->fields[fieldno2]));
+ return (strcoll(lp1->fields[fieldno1], lp2->fields[fieldno2]));
}
void
@@ -543,8 +546,13 @@ obsolete(argv)
* on the command line. (Well, we could reallocate
* the argv array, but that hardly seems worthwhile.)
*/
- if (ap[2] == '\0')
+ if (ap[2] == '\0' && (argv[1] == NULL ||
+ (strcmp(argv[1], "1") != 0 &&
+ strcmp(argv[1], "2") != 0))) {
ap[1] = '\01';
+ warnx("-a option used without an argument; "
+ "reverting to historical behavior");
+ }
break;
case 'j':
/*