summaryrefslogtreecommitdiff
path: root/src/join.c
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2011-01-27 07:17:16 +0000
committerPádraig Brady <P@draigBrady.com>2011-01-29 23:39:16 +0000
commit877ca5bf8588ae73a6ccc672e41f13c5b3943b14 (patch)
treeaecfb3505bf785ccb775305fb49bf89d712b0fa9 /src/join.c
parent32626bde6d68508109a99dfe0a089a0025f56085 (diff)
downloadcoreutils-877ca5bf8588ae73a6ccc672e41f13c5b3943b14.tar.xz
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.
Diffstat (limited to 'src/join.c')
-rw-r--r--src/join.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/join.c b/src/join.c
index ab7625183..941185c8a 100644
--- a/src/join.c
+++ b/src/join.c
@@ -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)