diff options
author | Jim Meyering <jim@meyering.net> | 1998-04-01 06:35:01 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1998-04-01 06:35:01 +0000 |
commit | a636450727936225e325f45722917c9dfaf0ba33 (patch) | |
tree | 8cec8b9d62cdc43341d4cca8d43e3b77c7ae770f /src/ls.c | |
parent | 6456a7d8ac207149c46dccb843c0d4cb528f0c76 (diff) | |
download | coreutils-a636450727936225e325f45722917c9dfaf0ba33.tar.xz |
(compare_ctime, rev_cmp_ctime, compare_mtime,
rev_cmp_mtime, compare_atime, rev_cmp_atime, compare_size,
rev_cmp_size): Use file name as secondary sort key to get
consistent sorting.
Diffstat (limited to 'src/ls.c')
-rw-r--r-- | src/ls.c | 40 |
1 files changed, 32 insertions, 8 deletions
@@ -1990,49 +1990,73 @@ sort_files (void) static int compare_ctime (const struct fileinfo *file1, const struct fileinfo *file2) { - return longdiff (file2->stat.st_ctime, file1->stat.st_ctime); + int diff = longdiff (file2->stat.st_ctime, file1->stat.st_ctime); + if (diff == 0) + diff = strcmp (file1->name, file2->name); + return diff; } static int rev_cmp_ctime (const struct fileinfo *file2, const struct fileinfo *file1) { - return longdiff (file2->stat.st_ctime, file1->stat.st_ctime); + int diff = longdiff (file2->stat.st_ctime, file1->stat.st_ctime); + if (diff == 0) + diff = strcmp (file1->name, file2->name); + return diff; } static int compare_mtime (const struct fileinfo *file1, const struct fileinfo *file2) { - return longdiff (file2->stat.st_mtime, file1->stat.st_mtime); + int diff = longdiff (file2->stat.st_mtime, file1->stat.st_mtime); + if (diff == 0) + diff = strcmp (file1->name, file2->name); + return diff; } static int rev_cmp_mtime (const struct fileinfo *file2, const struct fileinfo *file1) { - return longdiff (file2->stat.st_mtime, file1->stat.st_mtime); + int diff = longdiff (file2->stat.st_mtime, file1->stat.st_mtime); + if (diff == 0) + diff = strcmp (file1->name, file2->name); + return diff; } static int compare_atime (const struct fileinfo *file1, const struct fileinfo *file2) { - return longdiff (file2->stat.st_atime, file1->stat.st_atime); + int diff = longdiff (file2->stat.st_atime, file1->stat.st_atime); + if (diff == 0) + diff = strcmp (file1->name, file2->name); + return diff; } static int rev_cmp_atime (const struct fileinfo *file2, const struct fileinfo *file1) { - return longdiff (file2->stat.st_atime, file1->stat.st_atime); + int diff = longdiff (file2->stat.st_atime, file1->stat.st_atime); + if (diff == 0) + diff = strcmp (file1->name, file2->name); + return diff; } static int compare_size (const struct fileinfo *file1, const struct fileinfo *file2) { - return longdiff (file2->stat.st_size, file1->stat.st_size); + int diff = longdiff (file2->stat.st_size, file1->stat.st_size); + if (diff == 0) + diff = strcmp (file1->name, file2->name); + return diff; } static int rev_cmp_size (const struct fileinfo *file2, const struct fileinfo *file1) { - return longdiff (file2->stat.st_size, file1->stat.st_size); + int diff = longdiff (file2->stat.st_size, file1->stat.st_size); + if (diff == 0) + diff = strcmp (file1->name, file2->name); + return diff; } static int |