Use nanoseconds and then lexicographic ordering when the seconds of

the [acm]time are the same. I was going to use Scott's patch, but I
couldn't get the style quite right, so I used a patch of my own.

Submitted by:		Scott Mitchell <scott+freebsd at fishballoon.org>
MFC after:		3 weeks
This commit is contained in:
David Malone 2004-06-22 16:02:29 +00:00
parent 291cb0ac69
commit 60e52383e7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=130926

View File

@ -63,35 +63,71 @@ revnamecmp(const FTSENT *a, const FTSENT *b)
int
modcmp(const FTSENT *a, const FTSENT *b)
{
return (b->fts_statp->st_mtime - a->fts_statp->st_mtime);
if (b->fts_statp->st_mtimespec.tv_sec >
a->fts_statp->st_mtimespec.tv_sec)
return 1;
if (b->fts_statp->st_mtimespec.tv_sec <
a->fts_statp->st_mtimespec.tv_sec)
return -1;
if (b->fts_statp->st_mtimespec.tv_nsec >
a->fts_statp->st_mtimespec.tv_nsec)
return 1;
if (b->fts_statp->st_mtimespec.tv_nsec <
a->fts_statp->st_mtimespec.tv_nsec)
return -1;
return (strcoll(a->fts_name, b->fts_name));
}
int
revmodcmp(const FTSENT *a, const FTSENT *b)
{
return (a->fts_statp->st_mtime - b->fts_statp->st_mtime);
return (modcmp(b,a));
}
int
acccmp(const FTSENT *a, const FTSENT *b)
{
return (b->fts_statp->st_atime - a->fts_statp->st_atime);
if (b->fts_statp->st_atimespec.tv_sec >
a->fts_statp->st_atimespec.tv_sec)
return 1;
if (b->fts_statp->st_atimespec.tv_sec <
a->fts_statp->st_atimespec.tv_sec)
return -1;
if (b->fts_statp->st_atimespec.tv_nsec >
a->fts_statp->st_atimespec.tv_nsec)
return 1;
if (b->fts_statp->st_atimespec.tv_nsec <
a->fts_statp->st_atimespec.tv_nsec)
return -1;
return (strcoll(a->fts_name, b->fts_name));
}
int
revacccmp(const FTSENT *a, const FTSENT *b)
{
return (a->fts_statp->st_atime - b->fts_statp->st_atime);
return (acccmp(b,a));
}
int
statcmp(const FTSENT *a, const FTSENT *b)
{
return (b->fts_statp->st_ctime - a->fts_statp->st_ctime);
if (b->fts_statp->st_ctimespec.tv_sec >
a->fts_statp->st_ctimespec.tv_sec)
return 1;
if (b->fts_statp->st_ctimespec.tv_sec <
a->fts_statp->st_ctimespec.tv_sec)
return -1;
if (b->fts_statp->st_ctimespec.tv_nsec >
a->fts_statp->st_ctimespec.tv_nsec)
return 1;
if (b->fts_statp->st_ctimespec.tv_nsec <
a->fts_statp->st_ctimespec.tv_nsec)
return -1;
return (strcoll(a->fts_name, b->fts_name));
}
int
revstatcmp(const FTSENT *a, const FTSENT *b)
{
return (a->fts_statp->st_ctime - b->fts_statp->st_ctime);
return (statcmp(b,a));
}