mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-28 11:12:46 +00:00
Allow space between -a and its argument. Honour locale collating order
by using strcoll() instead of strcmp(). PR: 36270 Reviewed by: mike
This commit is contained in:
parent
ccc5b4e6f4
commit
fcb113145c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=95096
@ -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 ,
|
||||
|
@ -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':
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user