diff options
-rw-r--r-- | bin/ls/cmp.c | 48 |
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)); } |