Compare nanosecond field in timestamps.
Always do name comparison if other sort field is equal.
This commit is contained in:
parent
c603307d33
commit
0dc5640b54
88
bin/ls/cmp.c
88
bin/ls/cmp.c
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: cmp.c,v 1.8 1995/03/21 09:06:20 cgd Exp $ */
|
/* $NetBSD: cmp.c,v 1.9 1996/07/08 10:22:13 mycroft Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1989, 1993
|
* Copyright (c) 1989, 1993
|
||||||
@ -40,7 +40,7 @@
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)cmp.c 8.1 (Berkeley) 5/31/93";
|
static char sccsid[] = "@(#)cmp.c 8.1 (Berkeley) 5/31/93";
|
||||||
#else
|
#else
|
||||||
static char rcsid[] = "$NetBSD: cmp.c,v 1.8 1995/03/21 09:06:20 cgd Exp $";
|
static char rcsid[] = "$NetBSD: cmp.c,v 1.9 1996/07/08 10:22:13 mycroft Exp $";
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -71,42 +71,96 @@ int
|
|||||||
modcmp(a, b)
|
modcmp(a, b)
|
||||||
const FTSENT *a, *b;
|
const FTSENT *a, *b;
|
||||||
{
|
{
|
||||||
return (b->fts_statp->st_mtime - a->fts_statp->st_mtime);
|
if (b->fts_statp->st_mtime > a->fts_statp->st_mtime)
|
||||||
|
return (1);
|
||||||
|
else if (b->fts_statp->st_mtime < a->fts_statp->st_mtime)
|
||||||
|
return (-1);
|
||||||
|
else if (b->fts_statp->st_mtimensec > a->fts_statp->st_mtimensec)
|
||||||
|
return (1);
|
||||||
|
else if (b->fts_statp->st_mtimensec < a->fts_statp->st_mtimensec)
|
||||||
|
return (-1);
|
||||||
|
else
|
||||||
|
return (namecmp(a, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
revmodcmp(a, b)
|
revmodcmp(a, b)
|
||||||
const FTSENT *a, *b;
|
const FTSENT *a, *b;
|
||||||
{
|
{
|
||||||
return (a->fts_statp->st_mtime - b->fts_statp->st_mtime);
|
if (b->fts_statp->st_mtime < a->fts_statp->st_mtime)
|
||||||
|
return (1);
|
||||||
|
else if (b->fts_statp->st_mtime > a->fts_statp->st_mtime)
|
||||||
|
return (-1);
|
||||||
|
else if (b->fts_statp->st_mtimensec < a->fts_statp->st_mtimensec)
|
||||||
|
return (1);
|
||||||
|
else if (b->fts_statp->st_mtimensec > a->fts_statp->st_mtimensec)
|
||||||
|
return (-1);
|
||||||
|
else
|
||||||
|
return (revnamecmp(a, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
acccmp(a, b)
|
acccmp(a, b)
|
||||||
const FTSENT *a, *b;
|
const FTSENT *a, *b;
|
||||||
{
|
{
|
||||||
return (b->fts_statp->st_atime - a->fts_statp->st_atime);
|
if (b->fts_statp->st_atime > a->fts_statp->st_atime)
|
||||||
|
return (1);
|
||||||
|
else if (b->fts_statp->st_atime < a->fts_statp->st_atime)
|
||||||
|
return (-1);
|
||||||
|
else if (b->fts_statp->st_atimensec > a->fts_statp->st_atimensec)
|
||||||
|
return (1);
|
||||||
|
else if (b->fts_statp->st_atimensec < a->fts_statp->st_atimensec)
|
||||||
|
return (-1);
|
||||||
|
else
|
||||||
|
return (namecmp(a, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
revacccmp(a, b)
|
revacccmp(a, b)
|
||||||
const FTSENT *a, *b;
|
const FTSENT *a, *b;
|
||||||
{
|
{
|
||||||
return (a->fts_statp->st_atime - b->fts_statp->st_atime);
|
if (b->fts_statp->st_atime < a->fts_statp->st_atime)
|
||||||
|
return (1);
|
||||||
|
else if (b->fts_statp->st_atime > a->fts_statp->st_atime)
|
||||||
|
return (-1);
|
||||||
|
else if (b->fts_statp->st_atimensec < a->fts_statp->st_atimensec)
|
||||||
|
return (1);
|
||||||
|
else if (b->fts_statp->st_atimensec > a->fts_statp->st_atimensec)
|
||||||
|
return (-1);
|
||||||
|
else
|
||||||
|
return (revnamecmp(a, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
statcmp(a, b)
|
statcmp(a, b)
|
||||||
const FTSENT *a, *b;
|
const FTSENT *a, *b;
|
||||||
{
|
{
|
||||||
return (b->fts_statp->st_ctime - a->fts_statp->st_ctime);
|
if (b->fts_statp->st_ctime > a->fts_statp->st_ctime)
|
||||||
|
return (1);
|
||||||
|
else if (b->fts_statp->st_ctime < a->fts_statp->st_ctime)
|
||||||
|
return (-1);
|
||||||
|
else if (b->fts_statp->st_ctimensec > a->fts_statp->st_ctimensec)
|
||||||
|
return (1);
|
||||||
|
else if (b->fts_statp->st_ctimensec < a->fts_statp->st_ctimensec)
|
||||||
|
return (-1);
|
||||||
|
else
|
||||||
|
return (namecmp(a, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
revstatcmp(a, b)
|
revstatcmp(a, b)
|
||||||
const FTSENT *a, *b;
|
const FTSENT *a, *b;
|
||||||
{
|
{
|
||||||
return (a->fts_statp->st_ctime - b->fts_statp->st_ctime);
|
if (b->fts_statp->st_ctime < a->fts_statp->st_ctime)
|
||||||
|
return (1);
|
||||||
|
else if (b->fts_statp->st_ctime > a->fts_statp->st_ctime)
|
||||||
|
return (-1);
|
||||||
|
else if (b->fts_statp->st_ctimensec < a->fts_statp->st_ctimensec)
|
||||||
|
return (1);
|
||||||
|
else if (b->fts_statp->st_ctimensec > a->fts_statp->st_ctimensec)
|
||||||
|
return (-1);
|
||||||
|
else
|
||||||
|
return (revnamecmp(a, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -114,19 +168,21 @@ sizecmp(a, b)
|
|||||||
const FTSENT *a, *b;
|
const FTSENT *a, *b;
|
||||||
{
|
{
|
||||||
if (b->fts_statp->st_size > a->fts_statp->st_size)
|
if (b->fts_statp->st_size > a->fts_statp->st_size)
|
||||||
return 1;
|
return (1);
|
||||||
if (b->fts_statp->st_size < a->fts_statp->st_size)
|
if (b->fts_statp->st_size < a->fts_statp->st_size)
|
||||||
return -1;
|
return (-1);
|
||||||
return 0;
|
else
|
||||||
|
return (namecmp(a, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
revsizecmp(a, b)
|
revsizecmp(a, b)
|
||||||
const FTSENT *a, *b;
|
const FTSENT *a, *b;
|
||||||
{
|
{
|
||||||
if (a->fts_statp->st_size > b->fts_statp->st_size)
|
if (b->fts_statp->st_size < a->fts_statp->st_size)
|
||||||
return 1;
|
return (1);
|
||||||
if (a->fts_statp->st_size < b->fts_statp->st_size)
|
if (b->fts_statp->st_size > a->fts_statp->st_size)
|
||||||
return -1;
|
return (-1);
|
||||||
return 0;
|
else
|
||||||
|
return (revnamecmp(a, b));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user