Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Jun 2004 23:52:29 +0100
From:      Scott Mitchell <scott+freebsd@fishballoon.org>
To:        Dimitry Andric <dimitry@andric.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: /bin/ls sorting bug?
Message-ID:  <20040619225229.GE462@tuatara.fishballoon.org>
In-Reply-To: <14210101.20040619220601@andric.com>
References:  <20040619175007.GB462@tuatara.fishballoon.org> <414787887.20040619210137@andric.com> <20040619193545.GC462@tuatara.fishballoon.org> <14210101.20040619220601@andric.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Jun 19, 2004 at 10:06:01PM +0200, Dimitry Andric wrote:
> 
> Looking through ls source shows that the sorting is done by passing a
> comparison function to fts_open(3).  In the case of sorting by
> modification time, the *only* comparison made is of the mtime fields:

You did see the patch attached to my original post, right?  It modifies all
of these comparison functions to sort the two items by name (or reverse
name) in the case that their timestamps are equal.

> Note also that the fts(3) functions use qsort(3), which isn't stable,
> so you will not always get the order in which these entries are listed
> in the directory itself.

Indeed.  The proposed change will always give you a predictable ordering
for a given set of entries.

	Scott

-- 
===========================================================================
Scott Mitchell           | PGP Key ID | "Eagles may soar, but weasels
Cambridge, England       | 0x54B171B9 |  don't get sucked into jet engines"
scott at fishballoon.org | 0xAA775B8B |      -- Anon



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040619225229.GE462>