Tim Waugh 76a86e
--- coreutils-6.9/src/ls.c.ls-x	2007-06-13 14:27:36.000000000 +0100
Tim Waugh 76a86e
+++ coreutils-6.9/src/ls.c	2007-06-13 14:28:42.000000000 +0100
Tim Waugh 76a86e
@@ -4151,16 +4151,16 @@
Tim Waugh 76a86e
   size_t pos = 0;
Tim Waugh 76a86e
   size_t cols = calculate_columns (false);
Tim Waugh 76a86e
   struct column_info const *line_fmt = &column_info[cols - 1];
Tim Waugh 76a86e
-  size_t name_length = length_of_file_name_and_frills (cwd_file);
Tim Waugh 76a86e
+  struct fileinfo const *f = sorted_file[0];
Tim Waugh 76a86e
+  size_t name_length = length_of_file_name_and_frills (f);
Tim Waugh 76a86e
   size_t max_name_length = line_fmt->col_arr[0];
Tim Waugh 76a86e
 
Tim Waugh 76a86e
   /* Print first entry.  */
Tim Waugh 76a86e
-  print_file_name_and_frills (cwd_file);
Tim Waugh 76a86e
+  print_file_name_and_frills (f);
Tim Waugh 76a86e
 
Tim Waugh 76a86e
   /* Now the rest.  */
Tim Waugh 76a86e
   for (filesno = 1; filesno < cwd_n_used; ++filesno)
Tim Waugh 76a86e
     {
Tim Waugh 76a86e
-      struct fileinfo const *f;
Tim Waugh 76a86e
       size_t col = filesno % cols;
Tim Waugh 76a86e
 
Tim Waugh 76a86e
       if (col == 0)
Tim Waugh 76a86e
--- coreutils-6.9/tests/ls/Makefile.am.ls-x	2007-03-18 21:36:43.000000000 +0000
Tim Waugh 76a86e
+++ coreutils-6.9/tests/ls/Makefile.am	2007-06-13 14:28:42.000000000 +0100
Tim Waugh 76a86e
@@ -24,7 +24,7 @@
Tim Waugh 76a86e
   stat-dtype \
Tim Waugh 76a86e
   inode dangle file-type recursive dired infloop \
Tim Waugh 76a86e
   rt-1 time-1 symlink-slash follow-slink no-arg m-option \
Tim Waugh 76a86e
-  stat-vs-dirent
Tim Waugh 76a86e
+  stat-vs-dirent x-option
Tim Waugh 76a86e
 
Tim Waugh 76a86e
 EXTRA_DIST = $(TESTS)
Tim Waugh 76a86e
 TESTS_ENVIRONMENT = \
Tim Waugh 76a86e
--- /dev/null	2007-06-13 08:43:51.993263382 +0100
Tim Waugh 76a86e
+++ coreutils-6.9/tests/ls/x-option	2007-06-13 14:28:42.000000000 +0100
Tim Waugh 76a86e
@@ -0,0 +1,59 @@
Tim Waugh 76a86e
+#!/bin/sh
Tim Waugh 76a86e
+# Exercise the -x option.
Tim Waugh 76a86e
+
Tim Waugh 76a86e
+# Copyright (C) 2007 Free Software Foundation, Inc.
Tim Waugh 76a86e
+
Tim Waugh 76a86e
+# This program is free software; you can redistribute it and/or modify
Tim Waugh 76a86e
+# it under the terms of the GNU General Public License as published by
Tim Waugh 76a86e
+# the Free Software Foundation; either version 2 of the License, or
Tim Waugh 76a86e
+# (at your option) any later version.
Tim Waugh 76a86e
+
Tim Waugh 76a86e
+# This program is distributed in the hope that it will be useful,
Tim Waugh 76a86e
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
Tim Waugh 76a86e
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Tim Waugh 76a86e
+# GNU General Public License for more details.
Tim Waugh 76a86e
+
Tim Waugh 76a86e
+# You should have received a copy of the GNU General Public License
Tim Waugh 76a86e
+# along with this program; if not, write to the Free Software
Tim Waugh 76a86e
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
Tim Waugh 76a86e
+# 02110-1301, USA.
Tim Waugh 76a86e
+
Tim Waugh 76a86e
+if test "$VERBOSE" = yes; then
Tim Waugh 76a86e
+  set -x
Tim Waugh 76a86e
+  ls --version
Tim Waugh 76a86e
+fi
Tim Waugh 76a86e
+
Tim Waugh 76a86e
+. $srcdir/../envvar-check
Tim Waugh 76a86e
+. $srcdir/../lang-default
Tim Waugh 76a86e
+
Tim Waugh 76a86e
+pwd=`pwd`
Tim Waugh 76a86e
+t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
Tim Waugh 76a86e
+trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
Tim Waugh 76a86e
+trap '(exit $?); exit $?' 1 2 13 15
Tim Waugh 76a86e
+
Tim Waugh 76a86e
+framework_failure=0
Tim Waugh 76a86e
+mkdir -p $tmp || framework_failure=1
Tim Waugh 76a86e
+cd $tmp || framework_failure=1
Tim Waugh 76a86e
+mkdir subdir || framework_failure=1
Tim Waugh 76a86e
+touch subdir/b || framework_failure=1
Tim Waugh 76a86e
+touch subdir/a || framework_failure=1
Tim Waugh 76a86e
+
Tim Waugh 76a86e
+if test $framework_failure = 1; then
Tim Waugh 76a86e
+  echo "$0: failure in testing framework" 1>&2
Tim Waugh 76a86e
+  (exit 1); exit 1
Tim Waugh 76a86e
+fi
Tim Waugh 76a86e
+
Tim Waugh 76a86e
+fail=0
Tim Waugh 76a86e
+
Tim Waugh 76a86e
+# Coreutils 6.8 and 6.9 would output this in the wrong order.
Tim Waugh 76a86e
+ls -x subdir > out || fail=1
Tim Waugh 76a86e
+ls -rx subdir >> out || fail=1
Tim Waugh 76a86e
+cat <<\EOF > exp || fail=1
Tim Waugh 76a86e
+a  b
Tim Waugh 76a86e
+b  a
Tim Waugh 76a86e
+EOF
Tim Waugh 76a86e
+
Tim Waugh 76a86e
+cmp out exp || fail=1
Tim Waugh 76a86e
+test $fail = 1 && diff out exp 2> /dev/null
Tim Waugh 76a86e
+
Tim Waugh 76a86e
+(exit $fail); exit $fail
Tim Waugh 76a86e
--- coreutils-6.9/NEWS.ls-x	2007-03-22 21:19:45.000000000 +0000
Tim Waugh 76a86e
+++ coreutils-6.9/NEWS	2007-06-13 14:28:42.000000000 +0100
Tim Waugh 76a86e
@@ -13,6 +13,11 @@
Tim Waugh 76a86e
   Using pr -m -s (i.e. merging files, with TAB as the output separator)
Tim Waugh 76a86e
   no longer inserts extraneous spaces between output columns.
Tim Waugh 76a86e
 
Tim Waugh 76a86e
+** Bug fixes
Tim Waugh 76a86e
+
Tim Waugh 76a86e
+  ls -x DIR would sometimes output the wrong string in place of the
Tim Waugh 76a86e
+  first entry.  [introduced in coreutils-6.8]
Tim Waugh 76a86e
+
Tim Waugh 76a86e
 
Tim Waugh 76a86e
 * Noteworthy changes in release 6.8 (2007-02-24) [not-unstable]
Tim Waugh 76a86e