The last patch didn't update the cls help message... This one does.
Oskar ([EMAIL PROTECTED])
diff -u src/FileSet.cc.v0 src/FileSet.cc
--- src/FileSet.cc.v0 2003-01-25 10:18:09.000000000 +0100
+++ src/FileSet.cc 2003-01-25 10:23:36.000000000 +0100
@@ -197,6 +197,15 @@
return p1->GetRank()<p2->GetRank() ? -1 : 1;
}
+static int sort_date(const void *s1, const void *s2)
+{
+ const FileInfo *p1 = *(const FileInfo **) s1;
+ const FileInfo *p2 = *(const FileInfo **) s2;
+ if(p1->date==p2->date)
+ return sort_name(s1,s2);
+ return p1->date>p2->date ? -1 : 1;
+}
+
/* files_sort is an alias of files when sort == NAME (since
* files is always sorted by name), and an independant array
* of pointers (pointing to the same data) otherwise. */
@@ -223,6 +232,7 @@
case BYSIZE: qsort(files_sort, fnum, sizeof(FileInfo *), sort_size); break;
case DIRSFIRST: qsort(files_sort, fnum, sizeof(FileInfo *), sort_dirs); break;
case BYRANK: qsort(files_sort, fnum, sizeof(FileInfo *), sort_rank); break;
+ case BYDATE: qsort(files_sort, fnum, sizeof(FileInfo *), sort_date); break;
}
}
diff -u src/FileSet.h.v0 src/FileSet.h
--- src/FileSet.h.v0 2003-01-25 10:20:52.000000000 +0100
+++ src/FileSet.h 2003-01-25 10:21:06.000000000 +0100
@@ -108,7 +108,7 @@
class FileSet
{
public:
- enum sort_e { BYNAME, BYSIZE, DIRSFIRST, BYRANK };
+ enum sort_e { BYNAME, BYSIZE, DIRSFIRST, BYRANK, BYDATE };
private:
FileInfo **files;
diff -u src/commands.cc.v0 src/commands.cc
--- src/commands.cc.v0 2003-01-25 10:20:29.000000000 +0100
+++ src/commands.cc 2003-01-25 10:51:03.000000000 +0100
@@ -185,7 +185,7 @@
" -i, --nocase - case-insensitive pattern matching\n"
" -I, --sortnocase - sort names case-insensitively\n"
" -D, --dirsfirst - list directories first\n"
- " --sort=OPT - \"name\", \"size\"\n"
+ " --sort=OPT - \"name\", \"size\", \"date\"\n"
" -S - sort by file size\n"
" --user, --group, --perms, --date, --linkcount, --links\n"
" - show individual fields\n"
@@ -1332,6 +1332,7 @@
if(!strcmp(cls_options[longopt].name, "sort")) {
if(!strcasecmp(optarg, "name")) sort = FileSet::BYNAME;
else if(!strcasecmp(optarg, "size")) sort = FileSet::BYSIZE;
+ else if(!strcasecmp(optarg, "date")) sort = FileSet::BYDATE;
else return _("invalid argument for `--sort'");
} else if(!strcmp(cls_options[longopt].name, "filesize")) {
size_filesonly = true;