summaryrefslogtreecommitdiff
path: root/tests/misc/join.pl
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2016-01-12 16:29:32 +0000
committerPádraig Brady <P@draigBrady.com>2016-01-13 10:59:18 +0000
commitb2eadd109c3a508011705761dfe24a35180d925d (patch)
tree7efae6e5d2ba65a74b2e22e1160f0dd6a4013ce6 /tests/misc/join.pl
parentd44ae88199ebf44fe721c06621a7ffc442fa34be (diff)
downloadcoreutils-b2eadd109c3a508011705761dfe24a35180d925d.tar.xz
join,sort,uniq: with -z, treat '\n' as a field separator
* NEWS: Mention the change in behavior. * doc/coreutils.texi (newlineFieldSeparator): A new description, referenced from ({join,sort,uniq} invocation). * src/system.h (field_sep): A new inline function to determine if a character is a field separator. * src/join.c (usage): s/whitespace/blank/ to be more accurate wrt which characters are field separators. (xfields): s/isblank/field_sep/. * src/sort.c (inittables): Likewise. * src/uniq.c (find_field): Likewise. * tests/misc/join.pl: Adjust -z test, and add a test/example for processing the whole record with field processing. * tests/misc/sort.pl: Add -z test cases, including case with '\n'. * tests/misc/uniq.pl: Add -z -f test case with \n.
Diffstat (limited to 'tests/misc/join.pl')
-rwxr-xr-xtests/misc/join.pl9
1 files changed, 6 insertions, 3 deletions
diff --git a/tests/misc/join.pl b/tests/misc/join.pl
index 2a40f0095..4d399d8ae 100755
--- a/tests/misc/join.pl
+++ b/tests/misc/join.pl
@@ -290,10 +290,13 @@ my @tv = (
# missing last NUL at the end of the last line (=end of file)
['z4', '-z',
["a\0c\0e", "a\0b\0c"], "a\0c\0", 0],
-# edge-case: the embedded newlines should treated as
-# part of the nul-terminated line
+# With -z, embedded newlines are treated as field separators.
+# Note '\n' are converted to ' ' in this case.
['z5', '-z -a1 -a2',
- ["a\n1\0c 3\0","b\n8\0c 9\0"], "a\n1\0b\n8\0c 3 9\0"],
+ ["a\n\n1\0c 3\0", "a 2\0b\n8\0c 9\0"], "a 1 2\0b 8\0c 3 9\0"],
+# One can avoid field processing like:
+['z6', '-z -t ""',
+ ["a\n1\n\0", "a\n1\n\0"], "a\n1\n\0"],
);