bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

merge sort temp files


From: stan-bugcoreutils
Subject: merge sort temp files
Date: Fri, 30 Jul 2004 10:55:46 -0700 (PDT)

I'm using sort to merge sort two very large inputs, one being from stdin.
It's working slower than I would like because sort creates a temp file
when stdin is an input, I think, to keep from possibly clobbering input
files.

Would it be safe to put in a check that says if stdout is the output, that
it could safely not create temp files?  I've included the patch below.

Also, I don't understand the current behavior for stat on the output
file.  Why when it fails does it just return nfiles?

Stan

--- sort.c.orig 2004-07-30 10:42:21.000000000 -0700
+++ sort.c      2004-07-30 10:51:30.000000000 -0700
@@ -1915,19 +1915,18 @@
     {
       bool standard_input = STREQ (files[i], "-");

-      if (STREQ (outfile, files[i]) && ! standard_input)
-       return i;
-
       if (! got_outstat)
        {
          got_outstat = true;
-         if ((STREQ (outfile, "-")
-              ? fstat (STDOUT_FILENO, &outstat)
-              : stat (outfile, &outstat))
-             != 0)
+         if (STREQ (outfile, "-"))
+           return nfiles;
+         else if ( stat (outfile, &outstat) != 0 )
            return nfiles;
        }

+      if (STREQ (outfile, files[i]) && ! standard_input)
+       return i;
+
       if (((standard_input
            ? fstat (STDIN_FILENO, &instat)
            : stat (files[i], &instat))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]