mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
join: don't report disorder against an empty file
This allows one to use join as a field extractor like: join -a1 -o 1.3,1.1 - /dev/null * src/join.c (join): Don't flag unpairable lines when one of the files is empty. * tests/misc/join: Add a new test for empty input, and adjust a previous test that was only checking against empty input. * doc/coreutils.texi (join invocation): Document the change. * NEWS: Likewise.
This commit is contained in:
1 parent
32626bde6d
commit
877ca5bf85
4 files changed
+29
-9
No files matched your search
@@ -25,6 +25,12 @@ GNU coreutils NEWS -*- outline -*-
|
||||
output format from the first line in each file, to ensure
|
||||
the same number of fields are output for each line.
|
||||
|
||||
** Changes in behavior
|
||||
|
||||
join no longer reports disorder when one of the files is empty.
|
||||
This allows one to use join as a field extractor like:
|
||||
join -a1 -o 1.3,1.1 - /dev/null
|
||||
|
||||
|
||||
* Noteworthy changes in release 8.9 (2011-01-04) [stable]
|
||||
|
||||
|
||||
+13
-5
@@ -4787,11 +4787,17 @@ If there is an error it exits with nonzero status.
|
||||
@macro checkOrderOption{cmd}
|
||||
If the @option{--check-order} option is given, unsorted inputs will
|
||||
cause a fatal error message. If the option @option{--nocheck-order}
|
||||
is given, unsorted inputs will never cause an error message. If
|
||||
neither of these options is given, wrongly sorted inputs are diagnosed
|
||||
only if an input file is found to contain unpairable lines. If an
|
||||
input file is diagnosed as being unsorted, the @command{\cmd\} command
|
||||
will exit with a nonzero status (and the output should not be used).
|
||||
is given, unsorted inputs will never cause an error message. If neither
|
||||
of these options is given, wrongly sorted inputs are diagnosed
|
||||
only if an input file is found to contain unpairable
|
||||
@ifset JOIN_COMMAND
|
||||
lines, and when both input files are non empty.
|
||||
@end ifset
|
||||
@ifclear JOIN_COMMAND
|
||||
lines.
|
||||
@end ifclear
|
||||
If an input file is diagnosed as being unsorted, the @command{\cmd\}
|
||||
command will exit with a nonzero status (and the output should not be used).
|
||||
|
||||
Forcing @command{\cmd\} to process wrongly sorted input files
|
||||
containing unpairable lines by specifying @option{--nocheck-order} is
|
||||
@@ -5672,7 +5678,9 @@ c c1 c2
|
||||
b b1 b2
|
||||
@end example
|
||||
|
||||
@set JOIN_COMMAND
|
||||
@checkOrderOption{join}
|
||||
@clear JOIN_COMMAND
|
||||
|
||||
The defaults are:
|
||||
@itemize
|
||||
|
||||
+5
-3
@@ -736,7 +736,7 @@ join (FILE *fp1, FILE *fp2)
|
||||
seq2.count = 0;
|
||||
}
|
||||
|
||||
/* If the user did not specify --check-order, then we read the
|
||||
/* If the user did not specify --nocheck-order, then we read the
|
||||
tail ends of both inputs to verify that they are in order. We
|
||||
skip the rest of the tail once we have issued a warning for that
|
||||
file, unless we actually need to print the unpairable lines. */
|
||||
@@ -751,7 +751,8 @@ join (FILE *fp1, FILE *fp2)
|
||||
{
|
||||
if (print_unpairables_1)
|
||||
prjoin (seq1.lines[0], &uni_blank);
|
||||
seen_unpairable = true;
|
||||
if (seq2.count)
|
||||
seen_unpairable = true;
|
||||
while (get_line (fp1, &line, 1))
|
||||
{
|
||||
if (print_unpairables_1)
|
||||
@@ -765,7 +766,8 @@ join (FILE *fp1, FILE *fp2)
|
||||
{
|
||||
if (print_unpairables_2)
|
||||
prjoin (&uni_blank, seq2.lines[0]);
|
||||
seen_unpairable = true;
|
||||
if (seq1.count)
|
||||
seen_unpairable = true;
|
||||
while (get_line (fp2, &line, 2))
|
||||
{
|
||||
if (print_unpairables_2)
|
||||
|
||||
+5
-1
@@ -209,7 +209,11 @@ my @tv = (
|
||||
|
||||
# Before 6.10.143, this would mistakenly fail with the diagnostic:
|
||||
# join: File 1 is not in sorted order
|
||||
['chkodr-7', '-12', ["2 a\n1 b\n", ""], "", 0],
|
||||
['chkodr-7', '-12', ["2 a\n1 b\n", "2 c\n1 d"], "", 0],
|
||||
|
||||
# After 8.9, join doesn't report disorder by default
|
||||
# when comparing against an empty input file.
|
||||
['chkodr-8', '', ["2 a\n1 b\n", ""], "", 0],
|
||||
|
||||
# Test '--header' feature
|
||||
['header-1', '--header',
|
||||
|
||||
Reference in new issue
Block a user