From 3b92eaac53e1557ea923d6a395f753224a73d676 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Wed, 13 Feb 2008 14:30:33 +0000 Subject: sort: -z outputs NUL terminated lines. Closes bug 1591. --- coreutils/sort.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'coreutils/sort.c') diff --git a/coreutils/sort.c b/coreutils/sort.c index 1d6c59970..d8df4c532 100644 --- a/coreutils/sort.c +++ b/coreutils/sort.c @@ -32,7 +32,7 @@ enum { FLAG_u = 8, /* Unique */ FLAG_c = 0x10, /* Check: no output, exit(!ordered) */ FLAG_s = 0x20, /* Stable sort, no ascii fallback at end */ - FLAG_z = 0x40, /* Input is null terminated, not \n */ + FLAG_z = 0x40, /* Input and output is NUL terminated, not \n */ /* These can be applied to search keys, the previous four can't */ FLAG_b = 0x80, /* Ignore leading blanks */ FLAG_r = 0x100, /* Reverse */ @@ -396,8 +396,9 @@ int sort_main(int argc, char **argv) if (linecount) linecount = flag+1; } /* Print it */ + flag = (option_mask32 & FLAG_z) ? '\0' : '\n'; for (i = 0; i < linecount; i++) - fprintf(outfile, "%s\n", lines[i]); + fprintf(outfile, "%s%c", lines[i], flag); fflush_stdout_and_exit(EXIT_SUCCESS); } -- cgit v1.2.3