comm: fix NUL --output-delimiter with --total

* src/comm.c (compare_files): Handle the single character
--output-delimeter case separately so that NUL is appropriately
handled.
* doc/coreutils.texi (comm invocation): Fix the description
of --output-delimiter to say an empty delimeter is treated
as a NUL separator, rather than being disallowed.
* tests/misc/comm.pl: Add a test case.
Reported at https://bugs.debian.org/1014008
This commit is contained in:
Pádraig Brady committed 2022-08-27 18:41:10 +01:00
1 parent c88f08f9b6
commit 708ae170c9
3 files changed
+21 -6

No files matched your search

+16 -5
View File
@@ -395,11 +395,22 @@ compare_files (char **infiles)
char buf1[INT_BUFSIZE_BOUND (uintmax_t)];
char buf2[INT_BUFSIZE_BOUND (uintmax_t)];
char buf3[INT_BUFSIZE_BOUND (uintmax_t)];
printf ("%s%s%s%s%s%s%s%c",
umaxtostr (total[0], buf1), col_sep,
umaxtostr (total[1], buf2), col_sep,
umaxtostr (total[2], buf3), col_sep,
_("total"), delim);
if (col_sep_len == 1)
{ /* Separate to handle NUL char. */
printf ("%s%c%s%c%s%c%s%c",
umaxtostr (total[0], buf1), *col_sep,
umaxtostr (total[1], buf2), *col_sep,
umaxtostr (total[2], buf3), *col_sep,
_("total"), delim);
}
else
{
printf ("%s%s%s%s%s%s%s%c",
umaxtostr (total[0], buf1), col_sep,
umaxtostr (total[1], buf2), col_sep,
umaxtostr (total[2], buf3), col_sep,
_("total"), delim);
}
}
if (issued_disorder_warning[0] || issued_disorder_warning[1])