summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2002-04-20 01:55:19 +0000
committertjr <tjr@FreeBSD.org>2002-04-20 01:55:19 +0000
commit1cabb92eedd7ff58077f1efe99a8c791380e19d3 (patch)
tree4d44997949031b72ba29e38992a83ae306851749 /usr.bin
parentecccdb870361f2e0e62aea65bc8fa21a5171ea06 (diff)
downloadFreeBSD-src-1cabb92eedd7ff58077f1efe99a8c791380e19d3.zip
FreeBSD-src-1cabb92eedd7ff58077f1efe99a8c791380e19d3.tar.gz
Allow space between -a and its argument. Honour locale collating order
by using strcoll() instead of strcmp(). PR: 36270 Reviewed by: mike
Diffstat (limited to 'usr.bin')
-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 10e00f0..9a00849 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 84ea61b..77d6801 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':
/*
OpenPOWER on IntegriCloud