coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] join: add support \t as a field delimiter


From: Jongyeol Choi
Subject: [PATCH] join: add support \t as a field delimiter
Date: Tue, 19 Nov 2013 01:12:24 +0900

From a9c435ded74ee7d274e5ae2a0dd239ddb8255264 Mon Sep 17 00:00:00 2001
From: Jongyeol Choi <address@hidden>
Date: Tue, 19 Nov 2013 00:29:55 +0900
Subject: [PATCH] join: add support \t as a field delimiter

* src/join.c (main): In the getopt_long loop, handle the \t character.
* tests/misc/join.pl: Add a test case for \t.
---
 src/join.c         | 2 ++
 tests/misc/join.pl | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/src/join.c b/src/join.c
index 1da618d..2f6c6ff 100644
--- a/src/join.c
+++ b/src/join.c
@@ -1104,6 +1104,8 @@ main (int argc, char **argv)
               {
                 if (STREQ (optarg, "\\0"))
                   newtab = '\0';
+                else if (STREQ (optarg, "\\t"))
+                  newtab = '\t';
                 else
                   error (EXIT_FAILURE, 0, _("multi-character tab %s"),
                          quote (optarg));
diff --git a/tests/misc/join.pl b/tests/misc/join.pl
index 7e06f1e..55e71c0 100755
--- a/tests/misc/join.pl
+++ b/tests/misc/join.pl
@@ -55,6 +55,8 @@ my @tv = (
 ['3b', '-t ""', ["a 1\nb 1\n", "a 1\nb 2\n"], "a 1\n", 0],
 # use NUL as the field delimiter
 ['3c', '-t "\\0"', ["a\0a\n", "a\0b\n"], "a\0a\0b\n", 0],
+# use TAB as the field delimiter
+['3d', '-t "\\t"', ["a\ta\n", "a\tb\n"], "a\ta\tb\n", 0],

 # Just like -a1 and -a2 when there are no pairable lines
 ['4a', '-v 1', ["a 1\n", "b\n"],   "a 1\n",          0],
--
1.8.3.2


reply via email to

[Prev in Thread] Current Thread [Next in Thread]