diff options
author | Pádraig Brady <P@draigBrady.com> | 2016-01-08 14:31:27 +0000 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2016-01-13 10:59:56 +0000 |
commit | 826c98b02486dd9dbbab3d2381d5f778af42dd7a (patch) | |
tree | 24177f02817887f4ca8e63844e68770086c663ae /src | |
parent | a499a0ce583a8d941e50c4da450133e694994d17 (diff) | |
download | coreutils-826c98b02486dd9dbbab3d2381d5f778af42dd7a.tar.xz |
tac: support an empty (NUL) --separator
* doc/coreutils.texi (tac invocation): Mention the
NUL delineation with an empty --separator.
* src/tac.c (main): Allow an empty separator when -r not specified.
* tests/misc/tac.pl: Add test cases.
* NEWS: Mention the new feature.
Fixes http://bugs.gnu.org/8103
Diffstat (limited to 'src')
-rw-r--r-- | src/tac.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -639,8 +639,6 @@ main (int argc, char **argv) break; case 's': separator = optarg; - if (*separator == 0) - error (EXIT_FAILURE, 0, _("separator cannot be empty")); break; case_GETOPT_HELP_CHAR; case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); @@ -651,6 +649,9 @@ main (int argc, char **argv) if (sentinel_length == 0) { + if (*separator == 0) + error (EXIT_FAILURE, 0, _("separator cannot be empty")); + compiled_separator.buffer = NULL; compiled_separator.allocated = 0; compiled_separator.fastmap = compiled_separator_fastmap; @@ -661,7 +662,7 @@ main (int argc, char **argv) error (EXIT_FAILURE, 0, "%s", (error_message)); } else - match_length = sentinel_length = strlen (separator); + match_length = sentinel_length = *separator ? strlen (separator) : 1; read_size = INITIAL_READSIZE; while (sentinel_length >= read_size / 2) |