summaryrefslogtreecommitdiffstats
path: root/bin/ls
diff options
context:
space:
mode:
authordwmalone <dwmalone@FreeBSD.org>2004-06-22 16:02:29 +0000
committerdwmalone <dwmalone@FreeBSD.org>2004-06-22 16:02:29 +0000
commit2a386317a161ac67a3e2c58e2c191647c1567fbb (patch)
treed762a81f458c2eb80a3c1a3fcd4f7cdde19c6a3e /bin/ls
parent853033de651b9a9b37673c846130b9e045dcac90 (diff)
downloadFreeBSD-src-2a386317a161ac67a3e2c58e2c191647c1567fbb.zip
FreeBSD-src-2a386317a161ac67a3e2c58e2c191647c1567fbb.tar.gz
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
Diffstat (limited to 'bin/ls')
-rw-r--r--bin/ls/cmp.c48
1 files changed, 42 insertions, 6 deletions
diff --git a/bin/ls/cmp.c b/bin/ls/cmp.c
index aebb46a..17c856e 100644
--- a/bin/ls/cmp.c
+++ b/bin/ls/cmp.c
@@ -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));
}
OpenPOWER on IntegriCloud