diff options
author | Jim Meyering <jim@meyering.net> | 2001-03-13 08:48:57 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2001-03-13 08:48:57 +0000 |
commit | 811ade551454d824541555edb3ffcfc5ef4e3ee0 (patch) | |
tree | a6cd84aa2ce9d30f01eb85d646ca7a41cab2ddcf | |
parent | 593d17ffe4e4be8a96d123b98b49bcf0024c09ef (diff) | |
download | coreutils-811ade551454d824541555edb3ffcfc5ef4e3ee0.tar.xz |
(sort): If all the input files are empty, create an empty output file.
-rw-r--r-- | src/sort.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/sort.c b/src/sort.c index 981c97f06..f9534a1ec 100644 --- a/src/sort.c +++ b/src/sort.c @@ -1866,6 +1866,7 @@ sort (char **files, int nfiles, char const *output_file) { struct buffer buf; int n_temp_files = 0; + int output_file_created = 0; buf.alloc = 0; @@ -1909,6 +1910,7 @@ sort (char **files, int nfiles, char const *output_file) xfclose (fp, file); tfp = xfopen (output_file, "w"); temp_output = output_file; + output_file_created = 1; } else { @@ -1928,7 +1930,7 @@ sort (char **files, int nfiles, char const *output_file) xfclose (tfp, temp_output); - if (! n_temp_files) + if (output_file_created) goto finish; } xfclose (fp, file); @@ -1937,7 +1939,7 @@ sort (char **files, int nfiles, char const *output_file) finish: free (buf.buf); - if (n_temp_files) + if (! output_file_created) { int i = n_temp_files; struct tempnode *node; |