On 14/01/11 11:22, Jim Meyering wrote:
> I'm thinking of making yet another coreutils release.
> The du bug isn't that big a deal, but still.
> I prefer not to mix bug fixes and feature additions,
> and a few of the latter are coming.

I'd be inclined not to bother with a new release
unless we can have more consequential fixes.

> Does anyone have patches that would fit in a bug-fix release?

I can't connect at the moment, but perhaps
Kamil's patch here is needed?
https://bugzilla.redhat.com/show_bug.cgi?id=537463

I noticed a small issue this morning.
Assaf, the following warning shouldn't be printed, right?
The attached patch addresses that.

printf 'test\n1\n' | join --header -a1 - /dev/null
test
join: file 1 is not in sorted order
1



>From c36b20e51f028d13d06c27d86c0cf009313bacd3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]>
Date: Fri, 14 Jan 2011 08:46:21 +0000
Subject: [PATCH] join: ensure --header skips the order check with empty files

* src/join.c: Skip the header even if one of the files is empty.
* tests/misc/join: Add a test case.
* NEWS: Mention the fix
---
 NEWS            |    3 +++
 src/join.c      |   12 ++++++++----
 tests/misc/join |    6 ++++++
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/NEWS b/NEWS
index 9ccad63..82565b0 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,9 @@ GNU coreutils NEWS                                    -*- outline -*-
   rm -f no longer fails for EINVAL or EILSEQ on file systems that
   reject file names invalid for that file system.
 
+  join --header now skips the ordering check for the first line
+  even if the other file is empty.
+
 
 * Noteworthy changes in release 8.9 (2011-01-04) [stable]
 
diff --git a/src/join.c b/src/join.c
index afda5a1..07ac856 100644
--- a/src/join.c
+++ b/src/join.c
@@ -627,13 +627,17 @@ join (FILE *fp1, FILE *fp2)
   initseq (&seq2);
   getseq (fp2, &seq2, 2);
 
-  if (join_header_lines && seq1.count && seq2.count)
+  if (join_header_lines && (seq1.count || seq2.count))
     {
-      prjoin (seq1.lines[0], seq2.lines[0]);
+      struct line const *hline1 = seq1.count ? seq1.lines[0] : &uni_blank;
+      struct line const *hline2 = seq2.count ? seq2.lines[0] : &uni_blank;
+      prjoin (hline1, hline2);
       prevline[0] = NULL;
       prevline[1] = NULL;
-      advance_seq (fp1, &seq1, true, 1);
-      advance_seq (fp2, &seq2, true, 2);
+      if (seq1.count)
+        advance_seq (fp1, &seq1, true, 1);
+      if (seq2.count)
+        advance_seq (fp2, &seq2, true, 2);
     }
 
   while (seq1.count && seq2.count)
diff --git a/tests/misc/join b/tests/misc/join
index 3696a03..0299427 100755
--- a/tests/misc/join
+++ b/tests/misc/join
@@ -219,6 +219,12 @@ my @tv = (
  [ "ID1 Name\n1 A\n2 B\n", "ID2 Color\n1 red\n"],
    "ID1 Name Color\n1 A red\n", 0],
 
+# '--header' doesn't check order of a header
+# even if there is no header in the second file
+['header-6', '--header -a1',
+ [ "ID1 Name\n1 A\n", ""],
+   "ID1 Name\n1 A\n", 0],
+
 );
 
 # Convert the above old-style test vectors to the newer
-- 
1.7.3.4

Reply via email to