Hi Jim, On Sat July 25 2009 16:36:13 Jim Meyering wrote: > In the mean time, I've written a test for this. > Along the way, I noticed that ls -UR1 no longer works the > way I would expect, since the -R is effectively ignored. > This suggests that we may want to disable the optimization also > when -R is specified.
I've decided to make a trade-off. The optimization now works correctly when more directories are given as ls' arguments, but it is bypassed when -R or -s option is used. The patch should be applied on top of yours. Please prioritize review of this bug fix if possible. I am leaving for vacation tomorrow, far from internet. Thanks in advance! Kamil
From 8ed4a45632cd2d0caa6e9032b5dd6c3d4454fdaf Mon Sep 17 00:00:00 2001 From: Kamil Dudka <[email protected]> Date: Mon, 27 Jul 2009 11:37:47 +0200 Subject: [PATCH] ls -1U now works again (fixed regression from 7.0) --- NEWS | 1 + src/ls.c | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/NEWS b/NEWS index c98d64d..e476f2b 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,7 @@ GNU coreutils NEWS -*- outline -*- 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 diff --git a/src/ls.c b/src/ls.c index 48bc47e..07e9cf1 100644 --- 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; -- 1.6.2.5
_______________________________________________ Bug-coreutils mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-coreutils
