summaryrefslogtreecommitdiffstats
path: root/usr.bin/join/join.c
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/join/join.c
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/join/join.c')
-rw-r--r--usr.bin/join/join.c12
1 files changed, 10 insertions, 2 deletions
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