summaryrefslogtreecommitdiff
path: root/tests/misc/join
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2011-01-05 11:52:54 +0000
committerPádraig Brady <P@draigBrady.com>2011-01-29 23:08:31 +0000
commitd4db0cb1827730ed5536c12c0ebd024283b3a4db (patch)
tree091f857d1f547e9468501d14fc58291d2092b27e /tests/misc/join
parent68a734d66bbe72d5d4133c386fa77069dd77fb8c (diff)
downloadcoreutils-d4db0cb1827730ed5536c12c0ebd024283b3a4db.tar.xz
join: add -o 'auto' to output a constant number of fields per line
Lines with a different number of fields than the first line, will be truncated or padded. * src/join.c (prfields): A new function refactored from prjoin(), to output all but the join field. (prjoin): Don't swap line1 and line2 when line1 is blank so that the padding is applied to the right place. (main): Handle the -o 'auto' option. * tests/misc/join: Add 6 new cases to test the auto format. * NEWS: Mention the change in behavior. Suggestion from Assaf Gordon
Diffstat (limited to 'tests/misc/join')
-rwxr-xr-xtests/misc/join20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/misc/join b/tests/misc/join
index 3696a0381..3cf278b9f 100755
--- a/tests/misc/join
+++ b/tests/misc/join
@@ -127,6 +127,26 @@ my @tv = (
# From David Dyck
['9a', '', [" a 1\n b 2\n", " a Y\n b Z\n"], "a 1 Y\nb 2 Z\n", 0],
+# -o 'auto'
+['10a', '-a1 -a2 -e . -o auto',
+ ["a 1 2\nb 1\nd 1 2\n", "a 3 4\nb 3 4\nc 3 4\n"],
+ "a 1 2 3 4\nb 1 . 3 4\nc . . 3 4\nd 1 2 . .\n", 0],
+['10b', '-a1 -a2 -j3 -e . -o auto',
+ ["a 1 2\nb 1\nd 1 2\n", "a 3 4\nb 3 4\nc 3 4\n"],
+ "2 a 1 . .\n. b 1 . .\n2 d 1 . .\n4 . . a 3\n4 . . b 3\n4 . . c 3\n"],
+['10c', '-a1 -1 1 -2 4 -e. -o auto',
+ ["a 1 2\nb 1\nd 1 2\n", "a 3 4\nb 3 4\nc 3 4\n"],
+ "a 1 2 . . .\nb 1 . . . .\nd 1 2 . . .\n"],
+['10d', '-a2 -1 1 -2 4 -e. -o auto',
+ ["a 1 2\nb 1\nd 1 2\n", "a 3 4\nb 3 4\nc 3 4\n"],
+ ". . . a 3 4\n. . . b 3 4\n. . . c 3 4\n"],
+['10e', '-o auto',
+ ["a 1 2\nb 1 2 discard\n", "a 3 4\nb 3 4 discard\n"],
+ "a 1 2 3 4\nb 1 2 3 4\n"],
+['10f', '-t, -o auto',
+ ["a,1,,2\nb,1,2\n", "a,3,4\nb,3,4\n"],
+ "a,1,,2,3,4\nb,1,2,,3,4\n"],
+
# From Tim Smithers: fixed in 1.22l
['trailing-sp', '-t: -1 1 -2 1', ["a:x \n", "a:y \n"], "a:x :y \n", 0],