From b2eadd109c3a508011705761dfe24a35180d925d Mon Sep 17 00:00:00 2001 From: Pádraig Brady
Date: Tue, 12 Jan 2016 16:29:32 +0000
Subject: 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.
---
src/system.h | 7 +++++++
1 file changed, 7 insertions(+)
(limited to 'src/system.h')
diff --git a/src/system.h b/src/system.h
index c1c4a18a3..9898bc79c 100644
--- a/src/system.h
+++ b/src/system.h
@@ -155,6 +155,13 @@ enum
errors that the cast doesn't. */
static inline unsigned char to_uchar (char ch) { return ch; }
+/* '\n' is considered a field separator with --zero-terminated. */
+static inline bool
+field_sep (unsigned char ch)
+{
+ return isblank (ch) || ch == '\n';
+}
+
#include