]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
ls -1U dir arg ... now works again
authorKamil Dudka <kdudka@redhat.com>
Mon, 27 Jul 2009 09:37:47 +0000 (11:37 +0200)
committerJim Meyering <meyering@redhat.com>
Mon, 27 Jul 2009 15:10:39 +0000 (17:10 +0200)
* src/ls.c (print_dir): Emit "$dir_name:\n" *before* accumulating (and
possibly printing) directory entry names.
The bug was introduced in coreutils-7.0 via commit
8d974b00, 2008-07-30, "ls -U1 now uses constant memory".
Reported by Julian Bradfield.
* NEWS (Bug fixes): Mention it.

NEWS
THANKS
src/ls.c

diff --git a/NEWS b/NEWS
index 6190895094eadb11a039a306c0fc3abeef0db836..e476f2b96107f474227b6632ffd979638b8a2edb 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,14 +4,19 @@ GNU coreutils NEWS                                    -*- outline -*-
 
 ** Bug fixes
 
-  truncate -s failed to skip all whitespace in the option argument in
-  some locales.
+  ls -1U (with two or more arguments, at least one a nonempty directory)
+  would print entry names *before* the name of the containing directory.
+  Also fixed incorrect output of ls -1RU and ls -1sU.
+  [introduced in coreutils-7.0]
 
   sort now correctly ignores fields whose ending position is specified
   before the start position. Previously in numeric mode the remaining
   part of the line after the start position was used as the sort key.
   [This bug appears to have been present in "the beginning".]
 
+  truncate -s failed to skip all whitespace in the option argument in
+  some locales.
+
 ** New programs
 
   stdbuf: A new program to run a command with modified stdio buffering
diff --git a/THANKS b/THANKS
index bcd88f087b59b80cf6363577dee846102d200fff..9115528b6e6dd74df00c79a87c403e79f91a80c3 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -300,6 +300,7 @@ Joshua Hudson                       joshudson@gmail.com
 Josselin Mouette                    joss@debian.org
 Juan F. Codagnone                   juam@arnet.com.ar
 Juan M. Guerrero                    st001906@hrz1.hrz.tu-darmstadt.de
+Julian Bradfield                    jcb@inf.ed.ac.uk
 Jungshik Shin                       jshin@pantheon.yale.edu
 Jürgen Fluk                         louis@dachau.marco.de
 Jurriaan                            thunder7@xs4all.nl
index 48bc47e904080725b6ef2272c326931a1c1675f8..07e9cf1241e66be5b9c0367fe0b5c152d71eac9a 100644 (file)
--- a/src/ls.c
+++ b/src/ls.c
@@ -2456,6 +2456,19 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
       DEV_INO_PUSH (dir_stat.st_dev, dir_stat.st_ino);
     }
 
+  if (recursive | print_dir_name)
+    {
+      if (!first)
+       DIRED_PUTCHAR ('\n');
+      first = false;
+      DIRED_INDENT ();
+      PUSH_CURRENT_DIRED_POS (&subdired_obstack);
+      dired_pos += quote_name (stdout, realname ? realname : name,
+                              dirname_quoting_options, NULL);
+      PUSH_CURRENT_DIRED_POS (&subdired_obstack);
+      DIRED_FPUTS_LITERAL (":\n", stdout);
+    }
+
   /* Read the directory entries, and insert the subfiles into the `cwd_file'
      table.  */
 
@@ -2495,7 +2508,8 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
                 ls uses constant memory while processing the entries of
                 this directory.  Useful when there are many (millions)
                 of entries in a directory.  */
-             if (format == one_per_line && sort_type == sort_none)
+             if (format == one_per_line && sort_type == sort_none
+                     && !print_block_size && !recursive)
                {
                  /* We must call sort_files in spite of
                     "sort_type == sort_none" for its initialization
@@ -2531,19 +2545,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
   if (recursive)
     extract_dirs_from_files (name, command_line_arg);
 
-  if (recursive | print_dir_name)
-    {
-      if (!first)
-       DIRED_PUTCHAR ('\n');
-      first = false;
-      DIRED_INDENT ();
-      PUSH_CURRENT_DIRED_POS (&subdired_obstack);
-      dired_pos += quote_name (stdout, realname ? realname : name,
-                              dirname_quoting_options, NULL);
-      PUSH_CURRENT_DIRED_POS (&subdired_obstack);
-      DIRED_FPUTS_LITERAL (":\n", stdout);
-    }
-
   if (format == long_format || print_block_size)
     {
       const char *p;