aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2011-06-13 02:13:42 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2011-06-13 02:13:42 +0200
commitf194cc1f3376a26158940d91d0179a3e70233e10 (patch)
tree3bf78d8f6b64588fdbeb7dc83d337caa776f957a /coreutils
parentb307eabf4d47cbe224e35711838c8545f610205b (diff)
downloadbusybox-w32-f194cc1f3376a26158940d91d0179a3e70233e10.tar.gz
busybox-w32-f194cc1f3376a26158940d91d0179a3e70233e10.tar.bz2
busybox-w32-f194cc1f3376a26158940d91d0179a3e70233e10.zip
ls: make -v and -X actually work as intended
function old new delta strverscmp - 236 +236 sortcmp 186 254 +68 static.result_type - 60 +60 static.next_state 12 16 +4 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/ls.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c
index dec0f85f3..ee734734e 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -874,19 +874,27 @@ static int sortcmp(const void *a, const void *b)
874 // instead of branch forest 874 // instead of branch forest
875 if (sort_opts == SORT_SIZE) { 875 if (sort_opts == SORT_SIZE) {
876 dif = (d2->dn_size - d1->dn_size); 876 dif = (d2->dn_size - d1->dn_size);
877 } else if (sort_opts == SORT_ATIME) { 877 } else
878 if (sort_opts == SORT_ATIME) {
878 dif = (d2->dn_atime - d1->dn_atime); 879 dif = (d2->dn_atime - d1->dn_atime);
879 } else if (sort_opts == SORT_CTIME) { 880 } else
881 if (sort_opts == SORT_CTIME) {
880 dif = (d2->dn_ctime - d1->dn_ctime); 882 dif = (d2->dn_ctime - d1->dn_ctime);
881 } else if (sort_opts == SORT_MTIME) { 883 } else
884 if (sort_opts == SORT_MTIME) {
882 dif = (d2->dn_mtime - d1->dn_mtime); 885 dif = (d2->dn_mtime - d1->dn_mtime);
883 } else if (sort_opts == SORT_DIR) { 886 } else
887 if (sort_opts == SORT_DIR) {
884 dif = S_ISDIR(d2->dn_mode) - S_ISDIR(d1->dn_mode); 888 dif = S_ISDIR(d2->dn_mode) - S_ISDIR(d1->dn_mode);
885 /* } else if (sort_opts == SORT_VERSION) { */ 889 } else
886 /* } else if (sort_opts == SORT_EXT) { */ 890 if (sort_opts == SORT_VERSION) {
891 dif = strverscmp(d1->name, d2->name);
892 } else
893 if (sort_opts == SORT_EXT) {
894 dif = strcmp(strchrnul(d1->name, '.'), strchrnul(d2->name, '.'));
887 } 895 }
888 if (dif == 0) { 896 if (dif == 0) {
889 /* sort by name, or tie_breaker for other sorts */ 897 /* sort by name, use as tie breaker for other sorts */
890 if (ENABLE_LOCALE_SUPPORT) 898 if (ENABLE_LOCALE_SUPPORT)
891 dif = strcoll(d1->name, d2->name); 899 dif = strcoll(d1->name, d2->name);
892 else 900 else