aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-02-13 14:30:33 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-02-13 14:30:33 +0000
commit3b92eaac53e1557ea923d6a395f753224a73d676 (patch)
tree8d347a473b8be1b9fb8d27954cb39e7d50b2ae25 /coreutils
parent75cddd8eb514082c8f9945ae1976f97c4b0413b4 (diff)
downloadbusybox-w32-3b92eaac53e1557ea923d6a395f753224a73d676.tar.gz
busybox-w32-3b92eaac53e1557ea923d6a395f753224a73d676.tar.bz2
busybox-w32-3b92eaac53e1557ea923d6a395f753224a73d676.zip
sort: -z outputs NUL terminated lines. Closes bug 1591.
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/sort.c5
1 files changed, 3 insertions, 2 deletions
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 {
32 FLAG_u = 8, /* Unique */ 32 FLAG_u = 8, /* Unique */
33 FLAG_c = 0x10, /* Check: no output, exit(!ordered) */ 33 FLAG_c = 0x10, /* Check: no output, exit(!ordered) */
34 FLAG_s = 0x20, /* Stable sort, no ascii fallback at end */ 34 FLAG_s = 0x20, /* Stable sort, no ascii fallback at end */
35 FLAG_z = 0x40, /* Input is null terminated, not \n */ 35 FLAG_z = 0x40, /* Input and output is NUL terminated, not \n */
36/* These can be applied to search keys, the previous four can't */ 36/* These can be applied to search keys, the previous four can't */
37 FLAG_b = 0x80, /* Ignore leading blanks */ 37 FLAG_b = 0x80, /* Ignore leading blanks */
38 FLAG_r = 0x100, /* Reverse */ 38 FLAG_r = 0x100, /* Reverse */
@@ -396,8 +396,9 @@ int sort_main(int argc, char **argv)
396 if (linecount) linecount = flag+1; 396 if (linecount) linecount = flag+1;
397 } 397 }
398 /* Print it */ 398 /* Print it */
399 flag = (option_mask32 & FLAG_z) ? '\0' : '\n';
399 for (i = 0; i < linecount; i++) 400 for (i = 0; i < linecount; i++)
400 fprintf(outfile, "%s\n", lines[i]); 401 fprintf(outfile, "%s%c", lines[i], flag);
401 402
402 fflush_stdout_and_exit(EXIT_SUCCESS); 403 fflush_stdout_and_exit(EXIT_SUCCESS);
403} 404}